class Servitude::Cli::Service
Public Class Methods
common_start_options()
click to toggle source
# File lib/servitude/cli/service.rb, line 13 def self.common_start_options method_option :config, type: :string, aliases: '-c', desc: "The path for the config file" environment_option method_option :log_level, desc: "The log level", type: :string, aliases: '-o' method_option :log, desc: "The path for the log file", type: :string, aliases: '-l' method_option :threads, desc: "The number of threads", type: :numeric, aliases: '-t' end
environment_option()
click to toggle source
# File lib/servitude/cli/service.rb, line 5 def self.environment_option method_option :environment, desc: "The environment to execute in", type: :string, aliases: '-e' end
handle_no_command_error( name )
click to toggle source
# File lib/servitude/cli/service.rb, line 94 def self.handle_no_command_error( name ) puts "Unrecognized command: #{name}" end
pid_option()
click to toggle source
# File lib/servitude/cli/service.rb, line 9 def self.pid_option method_option :pid, desc: "The path for the PID file", type: :string end
Public Instance Methods
configuration( options, additional_options={} )
click to toggle source
# File lib/servitude/cli/service.rb, line 59 def configuration( options, additional_options={} ) unless options[:config] options = options.merge( config: host_namespace::DEFAULT_CONFIG_PATH ) end options = options.merge( additional_options ) host_namespace.configuration = configuration_class.load( host_namespace::DEFAULT_CONFIG_PATH, options ) end
configuration_class()
click to toggle source
# File lib/servitude/cli/service.rb, line 55 def configuration_class Servitude::Configuration end
host_namespace()
click to toggle source
# File lib/servitude/cli/service.rb, line 68 def host_namespace raise NotImplementedError end
restart()
click to toggle source
# File lib/servitude/cli/service.rb, line 24 def restart stop start_daemon end
start()
click to toggle source
# File lib/servitude/cli/service.rb, line 33 def start if options[:interactive] start_interactive else start_daemon end end
start_daemon()
click to toggle source
# File lib/servitude/cli/service.rb, line 48 def start_daemon server = Servitude::Daemon.new( host_namespace::APP_NAME, host_namespace::server_class, configuration( options, use_config: host_namespace::USE_CONFIG )) server.start end
start_interactive()
click to toggle source
# File lib/servitude/cli/service.rb, line 43 def start_interactive server = host_namespace::server_class.new( configuration( options, use_config: host_namespace::USE_CONFIG, log: 'STDOUT' )) server.start end
status()
click to toggle source
# File lib/servitude/cli/service.rb, line 77 def status result = Servitude::Daemon.new( host_namespace::APP_NAME, host_namespace::server_class, configuration( options, use_config: host_namespace::USE_CONFIG )).status at_exit { exit result } end
stop()
click to toggle source
# File lib/servitude/cli/service.rb, line 87 def stop server = Servitude::Daemon.new( host_namespace::APP_NAME, host_namespace::server_class, configuration( options, use_config: host_namespace::USE_CONFIG )) server.stop end