Class: Invoker::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/invoker/cli.rb

Defined Under Namespace

Classes: Pinger, Question, Tail, TailWatcher

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.start(*args) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/invoker/cli.rb', line 6

def self.start(*args)
  cli_args = args.flatten
  # If it is not a valid task, it is probably file argument
  if default_start_command?(cli_args)
    args = [cli_args.unshift("start")]
  end
  super(*args)
end

Instance Method Details

#add(name) ⇒ Object



50
51
52
# File 'lib/invoker/cli.rb', line 50

def add(name)
  unix_socket.send_command('add', process_name: name)
end

#add_http(name, port) ⇒ Object



55
56
57
# File 'lib/invoker/cli.rb', line 55

def add_http(name, port)
  unix_socket.send_command('add_http', process_name: name, port: port)
end

#listObject



75
76
77
78
79
# File 'lib/invoker/cli.rb', line 75

def list
  unix_socket.send_command('list') do |response_object|
    Invoker::ProcessPrinter.new(response_object).tap { |printer| printer.print_table }
  end
end

#reload(name) ⇒ Object



69
70
71
72
# File 'lib/invoker/cli.rb', line 69

def reload(name)
  signal = options[:signal] || 'INT'
  unix_socket.send_command('reload', process_name: name, signal: signal)
end

#remove(name) ⇒ Object



85
86
87
88
# File 'lib/invoker/cli.rb', line 85

def remove(name)
  signal = options[:signal] || 'INT'
  unix_socket.send_command('remove', process_name: name, signal: signal)
end

#setupObject



16
17
18
# File 'lib/invoker/cli.rb', line 16

def setup
  Invoker::Power::Setup.install
end

#start(file) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/invoker/cli.rb', line 37

def start(file)
  Invoker.setup_config_location
  port = options[:port] || 9000
  Invoker.daemonize = options[:daemon]
  Invoker.load_invoker_config(file, port)
  warn_about_terminal_notifier
  warn_about_old_configuration
  pinger = Invoker::CLI::Pinger.new(unix_socket)
  abort("Invoker is already running".color(:red)) if pinger.invoker_running?
  Invoker.commander.start_manager
end

#stopObject



91
92
93
# File 'lib/invoker/cli.rb', line 91

def stop
  Invoker.daemon.stop
end

#tail(*names) ⇒ Object



60
61
62
63
# File 'lib/invoker/cli.rb', line 60

def tail(*names)
  tailer = Invoker::CLI::Tail.new(names)
  tailer.run
end

#uninstallObject



27
28
29
# File 'lib/invoker/cli.rb', line 27

def uninstall
  Invoker::Power::Setup.uninstall
end

#versionObject



21
22
23
# File 'lib/invoker/cli.rb', line 21

def version
  Invoker::Logger.puts Invoker::VERSION
end