Class: Rspawn::CLI
- Inherits:
-
Thor
- Object
- Thor
- Rspawn::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/rspawn/cli.rb
Instance Method Summary collapse
-
#initialize(args = [], options = {}, config = {}) ⇒ CLI
constructor
A new instance of CLI.
- #restart(key) ⇒ Object
- #rm(key) ⇒ Object
- #start(key) ⇒ Object
- #status(key = nil) ⇒ Object
- #stop(key) ⇒ Object
- #tail(key) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ CLI
Returns a new instance of CLI.
17 18 19 20 21 |
# File 'lib/rspawn/cli.rb', line 17 def initialize(args = [], = {}, config = {}) super(args, , config) = config[:shell].base. @config = get_config(args.first) end |
Instance Method Details
#restart(key) ⇒ Object
31 32 33 |
# File 'lib/rspawn/cli.rb', line 31 def restart(key) start_action(['command'], 'restart') end |
#rm(key) ⇒ Object
58 59 60 |
# File 'lib/rspawn/cli.rb', line 58 def rm(key) @config.remove end |
#start(key) ⇒ Object
25 26 27 |
# File 'lib/rspawn/cli.rb', line 25 def start(key) start_action(['command'], 'start') end |
#status(key = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rspawn/cli.rb', line 42 def status(key = nil) keys = key.nil? ? Dir.glob(['root'] + "/*") : [key] keys = keys.map { |file| File.basename(file) } result = {} keys.each do |proc_name| option, command = get_config(proc_name).option option[:status] = capture_stdout do RspawnWorker.spawn!(option, ["status"]) end option[:command] = command result[proc_name] = option end puts JSON.pretty_generate(result) end |
#stop(key) ⇒ Object
36 37 38 39 |
# File 'lib/rspawn/cli.rb', line 36 def stop(key) option, command = @config.option RspawnWorker.spawn!(option, ["stop"]) end |
#tail(key) ⇒ Object
63 64 65 66 |
# File 'lib/rspawn/cli.rb', line 63 def tail(key) option, command = @config.option(nil) tail_log(option[:log_file]) end |
#version ⇒ Object
69 70 71 |
# File 'lib/rspawn/cli.rb', line 69 def version puts VERSION end |