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



66
67
68
# File 'lib/invoker/cli.rb', line 66

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

#add_http(name, port, ip = nil) ⇒ Object



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

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

#listObject



100
101
102
103
104
105
106
107
108
# File 'lib/invoker/cli.rb', line 100

def list
  unix_socket.send_command('list') do |response_object|
    if options[:raw]
      Invoker::ProcessPrinter.new(response_object).tap { |printer| printer.print_raw_text }
    else
      Invoker::ProcessPrinter.new(response_object).tap { |printer| printer.print_table }
    end
  end
end

#log(process_name) ⇒ Object



82
83
84
# File 'lib/invoker/cli.rb', line 82

def log(process_name)
  system("egrep -a '^#{process_name}' #{Invoker.daemon.log_file}")
end

#reload(name) ⇒ Object



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

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

#remove(name) ⇒ Object



114
115
116
117
# File 'lib/invoker/cli.rb', line 114

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

#setupObject



19
20
21
# File 'lib/invoker/cli.rb', line 19

def setup
  Invoker::Power::Setup.install(get_tld(options))
end

#start(file = nil) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/invoker/cli.rb', line 50

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

#stopObject



120
121
122
# File 'lib/invoker/cli.rb', line 120

def stop
  Invoker.daemon.stop
end

#tail(*names) ⇒ Object



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

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

#uninstallObject



30
31
32
# File 'lib/invoker/cli.rb', line 30

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

#versionObject



24
25
26
# File 'lib/invoker/cli.rb', line 24

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