Class: Servitude::Cli::Service

Inherits:
Base
  • Object
show all
Defined in:
lib/servitude/cli/service.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.common_start_optionsObject



13
14
15
16
17
18
19
# 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_optionObject



5
6
7
# 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) ⇒ Object



94
95
96
# File 'lib/servitude/cli/service.rb', line 94

def self.handle_no_command_error( name )
  puts "Unrecognized command: #{name}"
end

.pid_optionObject



9
10
11
# 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

Instance Method Details

#restartObject



24
25
26
27
# File 'lib/servitude/cli/service.rb', line 24

def restart
  stop
  start_daemon
end

#startObject



33
34
35
36
37
38
39
# File 'lib/servitude/cli/service.rb', line 33

def start
  if options[:interactive]
    start_interactive
  else
    start_daemon
  end
end

#statusObject



77
78
79
80
81
82
# 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

#stopObject



87
88
89
90
91
92
# 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