Class: Delayed::CLI
- Inherits:
-
Object
- Object
- Delayed::CLI
- Defined in:
- lib/delayed/cli.rb
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(args = ARGV) ⇒ CLI
constructor
A new instance of CLI.
- #parse_cli_options! ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args = ARGV) ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/delayed/cli.rb', line 13 def initialize(args = ARGV) self.class.instance = self @args = args # config that will be applied on Settings and passed to the created Pool @config = {} # CLI options that will be kept to this class @options = { config_file: Settings.default_worker_config_name, pid_folder: Settings.("tmp/pids"), tail_logs: true # only in FG mode } end |
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
8 9 10 |
# File 'lib/delayed/cli.rb', line 8 def instance @instance end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/delayed/cli.rb', line 11 def config @config end |
Instance Method Details
#parse_cli_options! ⇒ Object
58 59 60 61 |
# File 'lib/delayed/cli.rb', line 58 def option_parser.parse!(@args) @options end |
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/delayed/cli.rb', line 27 def run load_and_apply_config! command = @args.shift case command when "start" exit 1 if daemon.status(print: :alive) == :running daemon.daemonize! start when "stop" daemon.stop(kill: @options[:kill]) when "run" start when "status" if daemon.status exit 0 else exit 1 end when "restart" daemon.stop(kill: @options[:kill]) daemon.daemonize! start when nil puts option_parser.help else raise("Unknown command: #{command.inspect}") end end |