/usr/lib/ruby/vendor_ruby/berkshelf/api/generic_server.rb is in berkshelf-api 2.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | module Berkshelf::API
module GenericServer
class << self
def included(base)
base.send(:include, Celluloid)
base.send(:extend, ClassMethods)
end
end
module ClassMethods
# Returns the currently running instance of the including Class
#
# @return [Celluloid::Actor]
def instance
unless Application[server_name] && Application[server_name].alive?
raise NotStartedError, "#{server_name} not running"
end
Application[server_name]
end
# Set the name that the actor will be registered as with the applicaiton
#
# @param [#to_sym, nil]
#
# @return [Symbol]
def server_name(name = nil)
return @server_name if name.nil?
@server_name = name.to_sym
end
# Start the cache manager and add it to the application's registry.
#
# @note you probably do not want to manually start the cache manager unless you
# are testing the application. Start the entire application with {Berkshelf::API::Application.run}
def start(*args)
Application[server_name] = new(*args)
end
# Stop the cache manager if it's running.
#
# @note you probably don't want to manually stop the cache manager unless you are testing
# the application. Stop the entire application with {Berkshelf::API::Application.shutdown}
def stop
unless actor = Application[server_name]
actor.terminate
end
end
end
end
end
|