eye 0.8.pre2 → 0.8.rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +141 -0
- data/.travis.yml +5 -3
- data/README.md +1 -2
- data/Rakefile +5 -5
- data/bin/leye +9 -4
- data/bin/loader_eye +14 -15
- data/examples/custom_check.eye +24 -0
- data/examples/custom_trigger.eye +3 -1
- data/examples/delayed_job.eye +3 -3
- data/examples/dependency.eye +10 -11
- data/examples/leye_example/Eyefile +10 -0
- data/examples/notify.eye +3 -4
- data/examples/plugin/main.eye +5 -5
- data/examples/plugin/plugin.rb +10 -2
- data/examples/process_thin.rb +8 -8
- data/examples/processes/em.rb +18 -12
- data/examples/processes/forking.rb +5 -5
- data/examples/processes/sample.rb +46 -44
- data/examples/puma.eye +9 -8
- data/examples/rbenv.eye +5 -5
- data/examples/sidekiq.eye +3 -3
- data/examples/stress_test.eye +4 -4
- data/examples/syslog.eye +1 -1
- data/examples/test.eye +1 -2
- data/examples/thin-farm.eye +7 -8
- data/examples/triggers.eye +13 -15
- data/examples/unicorn.eye +12 -13
- data/eye.gemspec +14 -12
- data/lib/eye.rb +2 -3
- data/lib/eye/application.rb +5 -6
- data/lib/eye/checker.rb +36 -19
- data/lib/eye/checker/children_count.rb +1 -1
- data/lib/eye/checker/file_ctime.rb +1 -1
- data/lib/eye/checker/http.rb +13 -15
- data/lib/eye/checker/nop.rb +1 -0
- data/lib/eye/checker/socket.rb +60 -63
- data/lib/eye/checker/ssl_socket.rb +5 -5
- data/lib/eye/child_process.rb +6 -4
- data/lib/eye/cli.rb +50 -41
- data/lib/eye/cli/commands.rb +4 -5
- data/lib/eye/cli/render.rb +61 -41
- data/lib/eye/cli/server.rb +19 -16
- data/lib/eye/client.rb +1 -0
- data/lib/eye/config.rb +19 -19
- data/lib/eye/controller.rb +2 -3
- data/lib/eye/controller/commands.rb +1 -1
- data/lib/eye/controller/helpers.rb +2 -2
- data/lib/eye/controller/load.rb +18 -12
- data/lib/eye/controller/options.rb +1 -5
- data/lib/eye/controller/send_command.rb +21 -23
- data/lib/eye/controller/status.rb +17 -15
- data/lib/eye/dsl.rb +3 -0
- data/lib/eye/dsl/application_opts.rb +4 -3
- data/lib/eye/dsl/chain.rb +2 -2
- data/lib/eye/dsl/child_process_opts.rb +3 -3
- data/lib/eye/dsl/config_opts.rb +7 -7
- data/lib/eye/dsl/group_opts.rb +3 -3
- data/lib/eye/dsl/helpers.rb +1 -1
- data/lib/eye/dsl/main.rb +4 -3
- data/lib/eye/dsl/opts.rb +31 -28
- data/lib/eye/dsl/process_opts.rb +13 -7
- data/lib/eye/dsl/pure_opts.rb +13 -9
- data/lib/eye/dsl/validation.rb +48 -35
- data/lib/eye/group.rb +20 -6
- data/lib/eye/group/chain.rb +6 -6
- data/lib/eye/loader.rb +1 -1
- data/lib/eye/local.rb +9 -4
- data/lib/eye/logger.rb +11 -4
- data/lib/eye/notify.rb +10 -6
- data/lib/eye/notify/jabber.rb +1 -1
- data/lib/eye/notify/mail.rb +2 -2
- data/lib/eye/notify/slack.rb +4 -3
- data/lib/eye/process.rb +2 -0
- data/lib/eye/process/children.rb +4 -4
- data/lib/eye/process/commands.rb +28 -31
- data/lib/eye/process/config.rb +21 -19
- data/lib/eye/process/data.rb +11 -9
- data/lib/eye/process/monitor.rb +30 -29
- data/lib/eye/process/notify.rb +10 -10
- data/lib/eye/process/scheduler.rb +36 -31
- data/lib/eye/process/states.rb +5 -4
- data/lib/eye/process/states_history.rb +9 -3
- data/lib/eye/process/system.rb +5 -4
- data/lib/eye/process/trigger.rb +1 -5
- data/lib/eye/process/watchers.rb +6 -9
- data/lib/eye/reason.rb +4 -1
- data/lib/eye/server.rb +2 -1
- data/lib/eye/system.rb +16 -13
- data/lib/eye/system_resources.rb +13 -8
- data/lib/eye/trigger.rb +18 -16
- data/lib/eye/trigger/check_dependency.rb +7 -4
- data/lib/eye/trigger/flapping.rb +24 -7
- data/lib/eye/trigger/starting_guard.rb +7 -6
- data/lib/eye/trigger/stop_children.rb +2 -2
- data/lib/eye/trigger/transition.rb +1 -1
- data/lib/eye/trigger/wait_dependency.rb +3 -2
- data/lib/eye/utils.rb +4 -3
- data/lib/eye/utils/alive_array.rb +9 -4
- data/lib/eye/utils/celluloid_chain.rb +12 -10
- data/lib/eye/utils/mini_active_support.rb +16 -16
- data/lib/eye/utils/pmap.rb +2 -0
- data/lib/eye/utils/tail.rb +2 -2
- metadata +34 -4
- data/lib/eye/utils/leak_19.rb +0 -10
|
@@ -32,7 +32,7 @@ private
|
|
|
32
32
|
|
|
33
33
|
def ordered_by_date_children_pids
|
|
34
34
|
children = process.children.values
|
|
35
|
-
children.sort_by { |ch| Eye::SystemResources.start_time(ch.pid).to_i }.map
|
|
35
|
+
children.sort_by { |ch| Eye::SystemResources.start_time(ch.pid).to_i }.map(&:pid)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
end
|
data/lib/eye/checker/http.rb
CHANGED
|
@@ -21,46 +21,43 @@ class Eye::Checker::Http < Eye::Checker::Defer
|
|
|
21
21
|
@uri = URI.parse(url)
|
|
22
22
|
@proxy_uri = URI.parse(proxy_url) if proxy_url
|
|
23
23
|
@kind = case kind
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
when Fixnum then Net::HTTPResponse::CODE_TO_OBJ[kind.to_s]
|
|
25
|
+
when String, Symbol then Net.const_get("HTTP#{kind.to_s.camelize}") rescue Net::HTTPSuccess
|
|
26
|
+
else Net::HTTPSuccess
|
|
27
|
+
end
|
|
28
28
|
@open_timeout = (open_timeout || 3).to_f
|
|
29
29
|
@read_timeout = (read_timeout || timeout || 15).to_f
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def get_value
|
|
33
|
-
res = session.start{ |http| http.get(@uri.request_uri) }
|
|
34
|
-
{:
|
|
33
|
+
res = session.start { |http| http.get(@uri.request_uri) }
|
|
34
|
+
{ result: res }
|
|
35
35
|
|
|
36
36
|
rescue Timeout::Error => ex
|
|
37
37
|
debug { ex.inspect }
|
|
38
38
|
|
|
39
39
|
if defined?(Net::OpenTimeout) # for ruby 2.0
|
|
40
40
|
mes = ex.is_a?(Net::OpenTimeout) ? "OpenTimeout<#{@open_timeout}>" : "ReadTimeout<#{@read_timeout}>"
|
|
41
|
-
{:
|
|
41
|
+
{ exception: mes }
|
|
42
42
|
else
|
|
43
|
-
{:
|
|
43
|
+
{ exception: "Timeout<#{@open_timeout},#{@read_timeout}>" }
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
rescue => ex
|
|
47
|
-
{:
|
|
47
|
+
{ exception: "Error<#{ex.message}>" }
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def good?(value)
|
|
51
51
|
return false unless value[:result]
|
|
52
|
-
|
|
53
|
-
unless value[:result].kind_of?(@kind)
|
|
54
|
-
return false
|
|
55
|
-
end
|
|
52
|
+
return false unless value[:result].is_a?(@kind)
|
|
56
53
|
|
|
57
54
|
if pattern
|
|
58
55
|
matched = if pattern.is_a?(Regexp)
|
|
59
|
-
|
|
56
|
+
!!value[:result].body.match(pattern)
|
|
60
57
|
else
|
|
61
58
|
value[:result].body.include?(pattern.to_s)
|
|
62
59
|
end
|
|
63
|
-
value[:notice] = "missing '#{pattern
|
|
60
|
+
value[:notice] = "missing '#{pattern}'" unless matched
|
|
64
61
|
matched
|
|
65
62
|
else
|
|
66
63
|
true
|
|
@@ -102,4 +99,5 @@ private
|
|
|
102
99
|
Net::HTTP.new(@uri.host, @uri.port)
|
|
103
100
|
end
|
|
104
101
|
end
|
|
102
|
+
|
|
105
103
|
end
|
data/lib/eye/checker/nop.rb
CHANGED
data/lib/eye/checker/socket.rb
CHANGED
|
@@ -27,78 +27,75 @@ class Eye::Checker::Socket < Eye::Checker::Defer
|
|
|
27
27
|
|
|
28
28
|
if addr =~ %r[\Atcp://(.*?):(.*?)\z]
|
|
29
29
|
@socket_family = :tcp
|
|
30
|
-
@socket_addr =
|
|
31
|
-
@socket_port =
|
|
30
|
+
@socket_addr = Regexp.last_match(1)
|
|
31
|
+
@socket_port = Regexp.last_match(2).to_i
|
|
32
32
|
elsif addr =~ %r[\Aunix:(.*)\z]
|
|
33
33
|
@socket_family = :unix
|
|
34
|
-
@socket_path =
|
|
34
|
+
@socket_path = Regexp.last_match(1)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def get_value
|
|
39
39
|
sock = begin
|
|
40
|
-
Timeout
|
|
40
|
+
Timeout.timeout(@open_timeout) { open_socket }
|
|
41
41
|
rescue Timeout::Error
|
|
42
|
-
return { :
|
|
42
|
+
return { exception: "OpenTimeout<#{@open_timeout}>" }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
begin
|
|
47
|
-
Timeout::timeout(@read_timeout) do
|
|
48
|
-
_write_data(sock, send_data)
|
|
49
|
-
result = _read_data(sock)
|
|
45
|
+
return { result: :listen } unless send_data
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
begin
|
|
48
|
+
Timeout.timeout(@read_timeout) do
|
|
49
|
+
_write_data(sock, send_data)
|
|
50
|
+
result = _read_data(sock)
|
|
51
|
+
|
|
52
|
+
{ result: result }
|
|
53
|
+
end
|
|
54
|
+
rescue Timeout::Error
|
|
55
|
+
if protocol == :raw
|
|
56
|
+
return { result: @buffer }
|
|
57
|
+
else
|
|
58
|
+
return { exception: "ReadTimeout<#{@read_timeout}>" }
|
|
59
59
|
end
|
|
60
|
-
else
|
|
61
|
-
{ :result => :listen }
|
|
62
60
|
end
|
|
63
61
|
|
|
64
62
|
rescue Exception => e
|
|
65
|
-
{ :
|
|
63
|
+
{ exception: "Error<#{e.message}>" }
|
|
66
64
|
|
|
67
65
|
ensure
|
|
68
66
|
sock.close if sock
|
|
69
67
|
end
|
|
70
68
|
|
|
71
69
|
def good?(value)
|
|
72
|
-
return false
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
unless match
|
|
86
|
-
warn "proc #{expect_data} not matched (#{value[:result].truncate(30)}) answer"
|
|
87
|
-
value[:notice] = 'missing proc validation'
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
return match
|
|
70
|
+
return false unless value[:result]
|
|
71
|
+
|
|
72
|
+
return true unless expect_data
|
|
73
|
+
|
|
74
|
+
if expect_data.is_a?(Proc)
|
|
75
|
+
match = begin
|
|
76
|
+
!!expect_data[value[:result]]
|
|
77
|
+
rescue Object => ex
|
|
78
|
+
mes = "proc match failed with '#{ex.message}'"
|
|
79
|
+
error(mes)
|
|
80
|
+
value[:notice] = mes
|
|
81
|
+
return false
|
|
91
82
|
end
|
|
92
83
|
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
unless match
|
|
85
|
+
warn "proc #{expect_data} not matched (#{value[:result].truncate(30)}) answer"
|
|
86
|
+
value[:notice] = 'missing proc validation'
|
|
87
|
+
end
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
value[:notice] = "missing '#{expect_data.to_s}'"
|
|
98
|
-
return false
|
|
89
|
+
return match
|
|
99
90
|
end
|
|
100
91
|
|
|
101
|
-
return true
|
|
92
|
+
return true if expect_data.is_a?(Regexp) && expect_data.match(value[:result])
|
|
93
|
+
return true if value[:result].to_s == expect_data.to_s
|
|
94
|
+
|
|
95
|
+
warn "#{expect_data} not matched (#{value[:result].truncate(30)}) answer"
|
|
96
|
+
value[:notice] = "missing '#{expect_data}'"
|
|
97
|
+
|
|
98
|
+
false
|
|
102
99
|
end
|
|
103
100
|
|
|
104
101
|
def human_value(value)
|
|
@@ -131,28 +128,28 @@ private
|
|
|
131
128
|
|
|
132
129
|
def _write_data(socket, data)
|
|
133
130
|
case protocol
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
when :em_object
|
|
132
|
+
data = Marshal.dump(data)
|
|
133
|
+
socket.write([data.bytesize, data].pack('Na*'))
|
|
134
|
+
else
|
|
135
|
+
socket.write(data.to_s)
|
|
139
136
|
end
|
|
140
137
|
end
|
|
141
138
|
|
|
142
139
|
def _read_data(socket)
|
|
143
140
|
case protocol
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
141
|
+
when :em_object
|
|
142
|
+
content = ''
|
|
143
|
+
msg_size = socket.recv(4).unpack('N')[0] rescue 0
|
|
144
|
+
content << socket.recv(msg_size - content.length) while content.length < msg_size
|
|
145
|
+
if content.present?
|
|
146
|
+
Marshal.load(content) rescue 'corrupted_marshal'
|
|
147
|
+
end
|
|
148
|
+
when :raw
|
|
149
|
+
@buffer = ''
|
|
150
|
+
loop { @buffer << socket.recv(1) }
|
|
151
|
+
else
|
|
152
|
+
socket.readline.chop
|
|
156
153
|
end
|
|
157
154
|
end
|
|
158
155
|
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
require 'openssl'
|
|
2
2
|
|
|
3
3
|
class Eye::Checker::SslSocket < Eye::Checker::Socket
|
|
4
|
-
param :ctx, Hash, nil, {ssl_version: :SSLv23, verify_mode: OpenSSL::SSL::VERIFY_NONE}
|
|
5
4
|
|
|
6
|
-
#
|
|
5
|
+
# ctx params from http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html
|
|
7
6
|
#
|
|
8
7
|
# examples:
|
|
9
8
|
#
|
|
10
9
|
# check :ssl_socket, :addr => "tcp://127.0.0.1:443", :every => 5.seconds, :times => 1, :timeout => 1.second,
|
|
11
10
|
# :ctx => {ssl_version: :SSLv23, verify_mode: OpenSSL::SSL::VERIFY_NONE}
|
|
12
11
|
#
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
|
|
13
|
+
param :ctx, Hash, nil, ssl_version: :SSLv23, verify_mode: OpenSSL::SSL::VERIFY_NONE
|
|
15
14
|
|
|
16
15
|
private
|
|
17
16
|
|
|
@@ -23,6 +22,7 @@ private
|
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
def ctx_params
|
|
26
|
-
@ctx_params ||= OpenSSL::SSL::SSLContext.new
|
|
25
|
+
@ctx_params ||= OpenSSL::SSL::SSLContext.new.tap { |c| c.set_params(ctx) }
|
|
27
26
|
end
|
|
27
|
+
|
|
28
28
|
end
|
data/lib/eye/child_process.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'celluloid'
|
|
2
2
|
|
|
3
3
|
class Eye::ChildProcess
|
|
4
|
+
|
|
4
5
|
include Celluloid
|
|
5
6
|
|
|
6
7
|
# needs: kill_process
|
|
@@ -33,7 +34,7 @@ class Eye::ChildProcess
|
|
|
33
34
|
@parent = parent
|
|
34
35
|
@config = prepare_config(config)
|
|
35
36
|
@name = "child-#{pid}"
|
|
36
|
-
@full_name = [logger_prefix, @name]
|
|
37
|
+
@full_name = [logger_prefix, @name].join(':')
|
|
37
38
|
|
|
38
39
|
@watchers = {}
|
|
39
40
|
|
|
@@ -88,14 +89,15 @@ class Eye::ChildProcess
|
|
|
88
89
|
end
|
|
89
90
|
|
|
90
91
|
def signal(sig)
|
|
91
|
-
send_signal(sig) if
|
|
92
|
+
send_signal(sig) if pid
|
|
92
93
|
end
|
|
93
94
|
|
|
94
|
-
def status_data(
|
|
95
|
-
self_status_data(
|
|
95
|
+
def status_data(opts = {})
|
|
96
|
+
self_status_data(opts)
|
|
96
97
|
end
|
|
97
98
|
|
|
98
99
|
def prepare_command(command) # override
|
|
99
100
|
super.gsub('{PARENT_PID}', @parent.pid.to_s)
|
|
100
101
|
end
|
|
102
|
+
|
|
101
103
|
end
|
data/lib/eye/cli.rb
CHANGED
|
@@ -4,6 +4,7 @@ gem 'thor'
|
|
|
4
4
|
require 'thor'
|
|
5
5
|
|
|
6
6
|
class Eye::Cli < Thor
|
|
7
|
+
|
|
7
8
|
autoload :Server, 'eye/cli/server'
|
|
8
9
|
autoload :Commands, 'eye/cli/commands'
|
|
9
10
|
autoload :Render, 'eye/cli/render'
|
|
@@ -12,12 +13,16 @@ class Eye::Cli < Thor
|
|
|
12
13
|
include Eye::Cli::Commands
|
|
13
14
|
include Eye::Cli::Render
|
|
14
15
|
|
|
15
|
-
desc
|
|
16
|
-
method_option :json, :
|
|
16
|
+
desc 'info [MASK]', 'processes info'
|
|
17
|
+
method_option :json, type: :boolean, aliases: '-j'
|
|
18
|
+
method_option :procline, type: :boolean, aliases: '-p'
|
|
17
19
|
def info(mask = nil)
|
|
18
|
-
|
|
20
|
+
h = {}
|
|
21
|
+
h[:procline] = true if options[:procline]
|
|
22
|
+
|
|
23
|
+
res = cmd(:info_data, *Array(mask), h)
|
|
19
24
|
if mask && res[:subtree] && res[:subtree].empty?
|
|
20
|
-
error!(
|
|
25
|
+
error!('command :info, objects not found!')
|
|
21
26
|
end
|
|
22
27
|
|
|
23
28
|
if options[:json]
|
|
@@ -28,7 +33,7 @@ class Eye::Cli < Thor
|
|
|
28
33
|
end
|
|
29
34
|
end
|
|
30
35
|
|
|
31
|
-
desc
|
|
36
|
+
desc 'status NAME', 'return exit status for process name 0-up, 3-unmonitored'
|
|
32
37
|
def status(name)
|
|
33
38
|
res = cmd(:info_data, *Array(name))
|
|
34
39
|
es, msg = render_status(res)
|
|
@@ -36,11 +41,11 @@ class Eye::Cli < Thor
|
|
|
36
41
|
exit(es)
|
|
37
42
|
end
|
|
38
43
|
|
|
39
|
-
desc
|
|
40
|
-
method_option :config, :
|
|
41
|
-
method_option :json, :
|
|
44
|
+
desc 'xinfo', 'eye-deamon info (-c show current config)'
|
|
45
|
+
method_option :config, type: :boolean, aliases: '-c'
|
|
46
|
+
method_option :json, type: :boolean, aliases: '-j'
|
|
42
47
|
def xinfo
|
|
43
|
-
res = cmd(:debug_data, :
|
|
48
|
+
res = cmd(:debug_data, config: options[:config])
|
|
44
49
|
if options[:json]
|
|
45
50
|
say_json(res)
|
|
46
51
|
else
|
|
@@ -49,8 +54,8 @@ class Eye::Cli < Thor
|
|
|
49
54
|
end
|
|
50
55
|
end
|
|
51
56
|
|
|
52
|
-
desc
|
|
53
|
-
method_option :json, :
|
|
57
|
+
desc 'oinfo', 'onelined info'
|
|
58
|
+
method_option :json, type: :boolean, aliases: '-j'
|
|
54
59
|
def oinfo(mask = nil)
|
|
55
60
|
res = cmd(:short_data, *Array(mask))
|
|
56
61
|
if options[:json]
|
|
@@ -61,12 +66,12 @@ class Eye::Cli < Thor
|
|
|
61
66
|
end
|
|
62
67
|
end
|
|
63
68
|
|
|
64
|
-
desc
|
|
65
|
-
method_option :json, :
|
|
69
|
+
desc 'history [MASK,...]', 'processes history'
|
|
70
|
+
method_option :json, type: :boolean, aliases: '-j'
|
|
66
71
|
def history(*masks)
|
|
67
72
|
res = cmd(:history_data, *masks)
|
|
68
73
|
if !masks.empty? && res && res.empty?
|
|
69
|
-
error!(
|
|
74
|
+
error!('command :history, objects not found!')
|
|
70
75
|
end
|
|
71
76
|
if options[:json]
|
|
72
77
|
say_json(res)
|
|
@@ -76,18 +81,18 @@ class Eye::Cli < Thor
|
|
|
76
81
|
end
|
|
77
82
|
end
|
|
78
83
|
|
|
79
|
-
desc
|
|
80
|
-
method_option :foreground, :
|
|
84
|
+
desc 'load [CONF, ...]', 'load config (run eye-daemon if not) (-f foreground load)'
|
|
85
|
+
method_option :foreground, type: :boolean, aliases: '-f'
|
|
81
86
|
def load(*configs)
|
|
82
|
-
configs.map!{ |c| File.expand_path(c) }
|
|
87
|
+
configs.map! { |c| File.expand_path(c) }
|
|
83
88
|
|
|
84
89
|
if options[:foreground]
|
|
85
90
|
# in foreground we stop another server, and run just 1 current config version
|
|
86
|
-
error!(
|
|
91
|
+
error!('foreground expected only one config') if configs.size > 1
|
|
87
92
|
server_start_foreground(configs.first)
|
|
88
93
|
|
|
89
94
|
elsif server_started?
|
|
90
|
-
configs << Eye::Local.eyefile if Eye::Local.local_runner
|
|
95
|
+
configs << Eye::Local.eyefile if Eye::Local.local_runner && configs.empty? && Eye::Local.eyefile
|
|
91
96
|
say_load_result cmd(:load, *configs)
|
|
92
97
|
|
|
93
98
|
else
|
|
@@ -96,9 +101,9 @@ class Eye::Cli < Thor
|
|
|
96
101
|
end
|
|
97
102
|
end
|
|
98
103
|
|
|
99
|
-
desc
|
|
100
|
-
method_option :stop_all, :
|
|
101
|
-
method_option :timeout, :
|
|
104
|
+
desc 'quit', 'eye-daemon quit'
|
|
105
|
+
method_option :stop_all, type: :boolean, aliases: '-s'
|
|
106
|
+
method_option :timeout, type: :string, aliases: '-t', default: '600'
|
|
102
107
|
def quit
|
|
103
108
|
if options[:stop_all]
|
|
104
109
|
Eye::Local.client_timeout = options[:timeout].to_i
|
|
@@ -114,7 +119,7 @@ class Eye::Cli < Thor
|
|
|
114
119
|
# remove pid_file
|
|
115
120
|
File.delete(Eye::Local.pid_path) if File.exist?(Eye::Local.pid_path)
|
|
116
121
|
|
|
117
|
-
say "
|
|
122
|
+
say "Eye quit ಠ╭╮ಠ (#{Eye::Local.home})", :yellow
|
|
118
123
|
end
|
|
119
124
|
|
|
120
125
|
[:start, :stop, :restart, :unmonitor, :monitor, :delete, :match].each do |command|
|
|
@@ -124,60 +129,61 @@ class Eye::Cli < Thor
|
|
|
124
129
|
end
|
|
125
130
|
end
|
|
126
131
|
|
|
127
|
-
desc
|
|
132
|
+
desc 'force_restart MASK[,...]', 'restart by stop;start (not by restart_command)'
|
|
128
133
|
def force_restart(*masks)
|
|
129
134
|
send_command(:stop, *masks)
|
|
130
135
|
send_command(:start, *masks)
|
|
131
136
|
end
|
|
132
137
|
|
|
133
|
-
desc
|
|
138
|
+
desc 'signal SIG MASK[,...]', 'send signal to app,group or process'
|
|
134
139
|
def signal(sig, *masks)
|
|
135
140
|
send_command(:signal, sig, *masks)
|
|
136
141
|
end
|
|
137
142
|
|
|
138
|
-
desc
|
|
143
|
+
desc 'break MASK[,...]', 'break chain executing'
|
|
139
144
|
def break(*masks)
|
|
140
145
|
send_command(:break_chain, *masks)
|
|
141
146
|
end
|
|
142
147
|
|
|
143
|
-
desc
|
|
144
|
-
def trace(mask =
|
|
148
|
+
desc 'trace [MASK]', 'tracing log(tail + grep) for app,group or process'
|
|
149
|
+
def trace(mask = '')
|
|
145
150
|
log_trace(mask)
|
|
146
151
|
end
|
|
147
152
|
|
|
148
|
-
map [
|
|
149
|
-
desc
|
|
153
|
+
map ['-v', '--version'] => :version
|
|
154
|
+
desc 'version', 'version'
|
|
150
155
|
def version
|
|
151
156
|
say Eye::ABOUT
|
|
152
157
|
end
|
|
153
158
|
|
|
154
|
-
desc
|
|
155
|
-
method_option :host, :
|
|
156
|
-
method_option :verbose, :
|
|
159
|
+
desc 'check CONF', 'check config file syntax'
|
|
160
|
+
method_option :host, type: :string, aliases: '-h'
|
|
161
|
+
method_option :verbose, type: :boolean, aliases: '-v'
|
|
157
162
|
def check(conf)
|
|
158
163
|
conf = File.expand_path(conf) if conf && !conf.empty?
|
|
159
164
|
|
|
160
165
|
Eye::Local.host = options[:host] if options[:host]
|
|
161
166
|
Eye::Dsl.verbose = options[:verbose]
|
|
162
167
|
|
|
163
|
-
say_load_result Eye::Controller.new.check(conf), :
|
|
168
|
+
say_load_result Eye::Controller.new.check(conf), syntax: true
|
|
164
169
|
end
|
|
165
170
|
|
|
166
|
-
desc
|
|
167
|
-
method_option :host, :
|
|
168
|
-
method_option :verbose, :
|
|
171
|
+
desc 'explain CONF', 'explain config tree'
|
|
172
|
+
method_option :host, type: :string, aliases: '-h'
|
|
173
|
+
method_option :verbose, type: :boolean, aliases: '-v'
|
|
169
174
|
def explain(conf)
|
|
170
175
|
conf = File.expand_path(conf) if conf && !conf.empty?
|
|
171
176
|
|
|
172
177
|
Eye::Local.host = options[:host] if options[:host]
|
|
173
178
|
Eye::Dsl.verbose = options[:verbose]
|
|
174
179
|
|
|
175
|
-
say_load_result Eye::Controller.new.explain(conf), :
|
|
180
|
+
say_load_result Eye::Controller.new.explain(conf), print_config: true, syntax: true
|
|
176
181
|
end
|
|
177
182
|
|
|
178
|
-
desc
|
|
183
|
+
desc 'watch [MASK]', 'interactive processes info'
|
|
184
|
+
method_option :procline, type: :boolean, aliases: '-p'
|
|
179
185
|
def watch(*args)
|
|
180
|
-
error!(
|
|
186
|
+
error!('You should install watch utility') if `which watch`.empty?
|
|
181
187
|
|
|
182
188
|
cmd = if `watch --version 2>&1`.chop > '0.2.0'
|
|
183
189
|
"watch -n 1 --color #{$0} i #{args * ' '}"
|
|
@@ -185,12 +191,14 @@ class Eye::Cli < Thor
|
|
|
185
191
|
"watch -n 1 #{$0} i #{args * ' '}"
|
|
186
192
|
end
|
|
187
193
|
|
|
194
|
+
cmd += ' -p' if options[:procline]
|
|
195
|
+
|
|
188
196
|
pid = Process.spawn(cmd)
|
|
189
197
|
Process.waitpid(pid)
|
|
190
198
|
rescue Interrupt
|
|
191
199
|
end
|
|
192
200
|
|
|
193
|
-
desc
|
|
201
|
+
desc 'user_command CMD [MASK]', 'execute user_command (dsl command)'
|
|
194
202
|
def user_command(cmd, *args)
|
|
195
203
|
send_command(:user_command, cmd, *args)
|
|
196
204
|
end
|
|
@@ -224,4 +232,5 @@ private
|
|
|
224
232
|
def self.exit_on_failure?
|
|
225
233
|
true
|
|
226
234
|
end
|
|
235
|
+
|
|
227
236
|
end
|