watchmonkey_cli 1.9.1 → 1.10.0
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/VERSION +1 -1
- data/doc/checker_example.rb +8 -0
- data/lib/watchmonkey_cli.rb +1 -0
- data/lib/watchmonkey_cli/application.rb +2 -0
- data/lib/watchmonkey_cli/application/core.rb +17 -2
- data/lib/watchmonkey_cli/application/dispatch.rb +1 -1
- data/lib/watchmonkey_cli/checker.rb +12 -2
- data/lib/watchmonkey_cli/checkers/dev_pry.rb +29 -0
- data/lib/watchmonkey_cli/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2130727c6200a2fffef5220a52052df322b126e610dfdf18431f4c05841bd286
|
4
|
+
data.tar.gz: e8130e7bd3267c92a3352d102a577d7bd047c35905eae7291e9ddfe49da822e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '053523431494e83e9c6e72f4b1d1313cf3be03fe3f5a566deabcc2e2d22ec0db17d7d04f82a0fddbc91cd88024267d36d7a8bd1ffe7b5bc6c1990b6cfd1d41ba'
|
7
|
+
data.tar.gz: d4072ceafae6848acef9e34591cf1e33ddbf6df248eafa8f6018f0c1b7feb1c66e2238b388724a15cd5fa82669b9a6cd21b1f56f0518adc4c0ce040c730074b3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.10.0
|
data/doc/checker_example.rb
CHANGED
@@ -12,6 +12,14 @@ module MyWatchmonkeyCheckers
|
|
12
12
|
# e.g. my_checker "http://google.com", some_option: true
|
13
13
|
self.checker_name = "my_checker"
|
14
14
|
|
15
|
+
# Maximum amount of time this task may run before it gets killed.
|
16
|
+
# Set to 0/false to have no time limit whatsoever.
|
17
|
+
# Set to proc to evaluate at runtime
|
18
|
+
# Defaults to app.opts[:maxrt] if nil/unset
|
19
|
+
#self.maxrt = false
|
20
|
+
#self.maxrt = 5.minutes
|
21
|
+
#self.maxrt = ->(app, checker, args){ app.opts[:maxrt] && app.opts[:maxrt] * 2 }
|
22
|
+
|
15
23
|
# Called by configuration defining a check with all the arguments.
|
16
24
|
# e.g. my_checker "http://google.com", some_option: true
|
17
25
|
# Should invoke `app.enqueue` which will by default call `#check!` method with given arguments.
|
data/lib/watchmonkey_cli.rb
CHANGED
@@ -33,6 +33,7 @@ require "watchmonkey_cli/application/dispatch"
|
|
33
33
|
require "watchmonkey_cli/application"
|
34
34
|
|
35
35
|
# require buildin checkers
|
36
|
+
require "watchmonkey_cli/checkers/dev_pry"
|
36
37
|
require "watchmonkey_cli/checkers/ftp_availability"
|
37
38
|
require "watchmonkey_cli/checkers/mysql_replication"
|
38
39
|
require "watchmonkey_cli/checkers/ssl_expiration"
|
@@ -45,6 +45,8 @@ module WatchmonkeyCli
|
|
45
45
|
colorize: true, # -m flag
|
46
46
|
debug: false, # -d flag
|
47
47
|
threads: 10, # -t flag
|
48
|
+
maxrt: 120.seconds, # max runtime of a single task after which it will be terminated (may break SSH connection), 0/false to not limit runtime
|
49
|
+
conclosewait: 10, # max seconds to wait for connections to be closed (may never if they got killed by maxrt)
|
48
50
|
loop_forever: false, # (internal) loop forever (app mode)
|
49
51
|
loop_wait_empty: 1, # (internal) time to wait in thread if queue is empty
|
50
52
|
silent: false, # -s flag
|
@@ -81,7 +81,10 @@ module WatchmonkeyCli
|
|
81
81
|
|
82
82
|
def close_connections!
|
83
83
|
@connections.each do |type, clist|
|
84
|
-
clist.each
|
84
|
+
clist.each do |id, con|
|
85
|
+
debug "[SHUTDOWN] closing #{type} connection #{id} #{con}"
|
86
|
+
con.close!
|
87
|
+
end
|
85
88
|
end
|
86
89
|
end
|
87
90
|
|
@@ -98,7 +101,19 @@ module WatchmonkeyCli
|
|
98
101
|
begin
|
99
102
|
result = Checker::Result.new(checker, *a)
|
100
103
|
checker.debug(result.str_running)
|
101
|
-
checker.safe(result.str_safe) {
|
104
|
+
checker.safe(result.str_safe) {
|
105
|
+
timeout = checker.class.maxrt.nil? ? @opts[:maxrt] : checker.class.maxrt
|
106
|
+
timeout = timeout.call(self, checker, a) if timeout.respond_to?(:call)
|
107
|
+
begin
|
108
|
+
if timeout && timeout > 0
|
109
|
+
Timeout::timeout(timeout) { cb.call(result, *a) }
|
110
|
+
else
|
111
|
+
cb.call(result, *a)
|
112
|
+
end
|
113
|
+
rescue Timeout::Error => ex
|
114
|
+
result.error! "TIMEOUT: did not finish within #{timeout} seconds, task killed!"
|
115
|
+
end
|
116
|
+
}
|
102
117
|
fire(:result_dump, result, a, checker)
|
103
118
|
result.dump!
|
104
119
|
ensure
|
@@ -17,6 +17,14 @@ module WatchmonkeyCli
|
|
17
17
|
@checker_name = name
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.maxrt
|
21
|
+
@maxrt
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.maxrt= seconds
|
25
|
+
@maxrt = seconds
|
26
|
+
end
|
27
|
+
|
20
28
|
module AppHelper
|
21
29
|
def init_checkers!
|
22
30
|
@checkers = {}
|
@@ -168,8 +176,10 @@ module WatchmonkeyCli
|
|
168
176
|
error "#{descriptor}retry #{tries} reason is `#{e.class}: #{e.message}'"
|
169
177
|
e.backtrace.each{|l| debug "\t\t#{l}" }
|
170
178
|
end
|
171
|
-
|
172
|
-
|
179
|
+
unless $wm_runtime_exiting
|
180
|
+
sleep 1
|
181
|
+
retry
|
182
|
+
end
|
173
183
|
end
|
174
184
|
error "#{descriptor}retries exceeded"
|
175
185
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module WatchmonkeyCli
|
2
|
+
module Checkers
|
3
|
+
class DevPry < Checker
|
4
|
+
self.checker_name = "dev_pry"
|
5
|
+
self.maxrt = false
|
6
|
+
|
7
|
+
def enqueue host, opts = {}
|
8
|
+
host = app.fetch_connection(:loopback, :local) if !host || host == :local
|
9
|
+
host = app.fetch_connection(:ssh, host) if host.is_a?(Symbol)
|
10
|
+
app.enqueue(self, host, opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def check! result, host, opts = {}
|
14
|
+
if app.opts[:threads] > 1
|
15
|
+
result.error! "pry only works properly within the main thread, run watchmonkey with `-t0`"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
require "pry"
|
21
|
+
binding.pry
|
22
|
+
1+1 # pry may bug out otherwise if it's last statement
|
23
|
+
rescue LoadError => ex
|
24
|
+
result.error! "pry is required (gem install pry)! #{ex.class}: #{ex.message}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watchmonkey_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Pachnit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/watchmonkey_cli/application/dispatch.rb
|
124
124
|
- lib/watchmonkey_cli/application/output_helper.rb
|
125
125
|
- lib/watchmonkey_cli/checker.rb
|
126
|
+
- lib/watchmonkey_cli/checkers/dev_pry.rb
|
126
127
|
- lib/watchmonkey_cli/checkers/ftp_availability.rb
|
127
128
|
- lib/watchmonkey_cli/checkers/mysql_replication.rb
|
128
129
|
- lib/watchmonkey_cli/checkers/ssl_expiration.rb
|