resurrected_god 1.1.0 → 1.1.2
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/History.md +10 -0
- data/README.md +1 -1
- data/ext/god/kqueue_handler.c +2 -1
- data/ext/god/netlink_handler.c +2 -1
- data/lib/god/cli/command.rb +1 -1
- data/lib/god/cli/run.rb +2 -2
- data/lib/god/conditions/complex.rb +3 -3
- data/lib/god/conditions/cpu_usage.rb +1 -1
- data/lib/god/conditions/memory_usage.rb +1 -1
- data/lib/god/conditions/process_running.rb +3 -3
- data/lib/god/contact.rb +3 -3
- data/lib/god/logger.rb +2 -2
- data/lib/god/process.rb +5 -5
- data/lib/god/system/slash_proc_poller.rb +1 -1
- data/lib/god/timeline.rb +1 -1
- data/lib/god/version.rb +1 -1
- data/lib/god/watch.rb +3 -2
- data/lib/god.rb +7 -8
- metadata +33 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7465cd872f35560c971fa2a4a0d1571b37129d7012d309f9e76b37bdb4e07e4
|
|
4
|
+
data.tar.gz: 33fec16027eaccb0df55a0895ea139ceed978e98f8c868596e00bfa2ca87bff1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ef0c4e6171d31c292a8f9b76f7d813f434c31de284a6fef9fafe947226c807d5110f7e604dd1fc950d9f33c35cd4bd3c485c00e9498ccb51942915829d1dbb3
|
|
7
|
+
data.tar.gz: 2c831bfd22c3887c9445fe22d15eb6ccfb3787b3b61bdbf40170e6497b305704d6dfac5cb897f72a5b7e4a5e7f8d2890675cb481e7e7e13cde13467e62d57c63
|
data/History.md
CHANGED
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@ ResurrectedGod: The Ruby Framework for Process Management
|
|
|
2
2
|
==============================================
|
|
3
3
|
|
|
4
4
|
[](https://badge.fury.io/rb/resurrected_god)
|
|
5
|
-
[](https://github.com/mishina2228/resurrected_god/actions/workflows/test.yml)
|
|
6
6
|
[](https://rubydoc.info/gems/resurrected_god)
|
|
7
7
|
[](https://codeclimate.com/github/mishina2228/resurrected_god/maintainability)
|
|
8
8
|
[](https://codecov.io/gh/mishina2228/resurrected_god)
|
data/ext/god/kqueue_handler.c
CHANGED
data/ext/god/netlink_handler.c
CHANGED
data/lib/god/cli/command.rb
CHANGED
|
@@ -27,7 +27,7 @@ module God
|
|
|
27
27
|
def dispatch
|
|
28
28
|
if %w[load status signal log quit terminate].include?(@command)
|
|
29
29
|
setup
|
|
30
|
-
send("#{@command}_command")
|
|
30
|
+
send(:"#{@command}_command")
|
|
31
31
|
elsif %w[start stop restart monitor unmonitor remove].include?(@command)
|
|
32
32
|
setup
|
|
33
33
|
lifecycle_command
|
data/lib/god/cli/run.rb
CHANGED
|
@@ -111,13 +111,13 @@ module God
|
|
|
111
111
|
def setup_logging
|
|
112
112
|
log_file = God.log_file
|
|
113
113
|
log_file = File.expand_path(@options[:log]) if @options[:log]
|
|
114
|
-
log_file =
|
|
114
|
+
log_file = File::NULL if !log_file && @options[:daemonize]
|
|
115
115
|
return unless log_file
|
|
116
116
|
|
|
117
117
|
puts "Sending output to log file: #{log_file}" unless @options[:daemonize]
|
|
118
118
|
|
|
119
119
|
# reset file descriptors
|
|
120
|
-
$stdin.reopen
|
|
120
|
+
$stdin.reopen File::NULL
|
|
121
121
|
$stdout.reopen(log_file, 'a')
|
|
122
122
|
$stderr.reopen $stdout
|
|
123
123
|
$stdout.sync = true
|
|
@@ -64,15 +64,15 @@ module God
|
|
|
64
64
|
# nil @this here by initially setting res to true or false,
|
|
65
65
|
# depending on whether the first operator used is AND or OR
|
|
66
66
|
# respectively.
|
|
67
|
-
@op_stack[0]
|
|
67
|
+
@op_stack[0].anybits?(AND)
|
|
68
68
|
else
|
|
69
69
|
@this.test
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
@op_stack.each do |op|
|
|
73
73
|
cond = @oper_stack.shift
|
|
74
|
-
value = op
|
|
75
|
-
if op
|
|
74
|
+
value = op.anybits?(NOT) ? !cond.test : cond.test
|
|
75
|
+
if op.anybits?(AND)
|
|
76
76
|
res &&= value
|
|
77
77
|
else
|
|
78
78
|
res ||= value
|
|
@@ -64,7 +64,7 @@ module God
|
|
|
64
64
|
@timeline.push(process.percent_cpu)
|
|
65
65
|
self.info = []
|
|
66
66
|
|
|
67
|
-
history = @timeline.map { |x| "#{x > above
|
|
67
|
+
history = @timeline.map { |x| "#{'*' if x > above}#{x}%%" }.join(', ')
|
|
68
68
|
|
|
69
69
|
if @timeline.count { |x| x > above } >= times.first
|
|
70
70
|
self.info = "cpu out of bounds [#{history}]"
|
|
@@ -66,7 +66,7 @@ module God
|
|
|
66
66
|
@timeline.push(process.memory)
|
|
67
67
|
self.info = []
|
|
68
68
|
|
|
69
|
-
history = @timeline.map { |x| "#{x > above
|
|
69
|
+
history = @timeline.map { |x| "#{'*' if x > above}#{x}kb" }.join(', ')
|
|
70
70
|
|
|
71
71
|
if @timeline.count { |x| x > above } >= times.first
|
|
72
72
|
self.info = "memory out of bounds [#{history}]"
|
|
@@ -48,13 +48,13 @@ module God
|
|
|
48
48
|
active = pid && System::Process.new(pid).exists?
|
|
49
49
|
|
|
50
50
|
if running && active
|
|
51
|
-
info.
|
|
51
|
+
info.push('process is running')
|
|
52
52
|
true
|
|
53
53
|
elsif !running && !active
|
|
54
|
-
info.
|
|
54
|
+
info.push('process is not running')
|
|
55
55
|
true
|
|
56
56
|
else
|
|
57
|
-
info.
|
|
57
|
+
info.push('process is not running') if running
|
|
58
58
|
false
|
|
59
59
|
end
|
|
60
60
|
end
|
data/lib/god/contact.rb
CHANGED
|
@@ -28,7 +28,7 @@ module God
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def arg(name)
|
|
31
|
-
instance_variable_get("@#{name}") || self.class.instance_variable_get("@#{name}")
|
|
31
|
+
instance_variable_get(:"@#{name}") || self.class.instance_variable_get(:"@#{name}")
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# Normalize the given notify specification into canonical form.
|
|
@@ -47,7 +47,7 @@ module God
|
|
|
47
47
|
when String
|
|
48
48
|
{ contacts: Array(spec) }
|
|
49
49
|
when Array
|
|
50
|
-
raise ArgumentError, 'contains non-String elements' unless spec.all?
|
|
50
|
+
raise ArgumentError, 'contains non-String elements' unless spec.all?(String)
|
|
51
51
|
|
|
52
52
|
{ contacts: spec }
|
|
53
53
|
when Hash
|
|
@@ -60,7 +60,7 @@ module God
|
|
|
60
60
|
when String
|
|
61
61
|
# valid
|
|
62
62
|
when Array
|
|
63
|
-
raise ArgumentError, 'has a :contacts key containing non-String elements' unless contacts.all?
|
|
63
|
+
raise ArgumentError, 'has a :contacts key containing non-String elements' unless contacts.all?(String)
|
|
64
64
|
# valid
|
|
65
65
|
else
|
|
66
66
|
raise ArgumentError, 'must have a :contacts key pointing to a String or Array of Strings'
|
data/lib/god/logger.rb
CHANGED
|
@@ -12,7 +12,7 @@ module God
|
|
|
12
12
|
|
|
13
13
|
# Instantiate a new Logger object
|
|
14
14
|
def initialize(io = $stdout)
|
|
15
|
-
super
|
|
15
|
+
super
|
|
16
16
|
self.logs = {}
|
|
17
17
|
@mutex = Mutex.new
|
|
18
18
|
@capture = nil
|
|
@@ -24,7 +24,7 @@ module God
|
|
|
24
24
|
|
|
25
25
|
def level=(lev)
|
|
26
26
|
SysLogger.level = SimpleLogger::CONSTANT_TO_SYMBOL[lev] if Logger.syslog
|
|
27
|
-
super
|
|
27
|
+
super
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# Log a message
|
data/lib/god/process.rb
CHANGED
|
@@ -9,7 +9,7 @@ module God
|
|
|
9
9
|
:stop_timeout, :stop_signal, :umask
|
|
10
10
|
|
|
11
11
|
def initialize
|
|
12
|
-
self.log =
|
|
12
|
+
self.log = File::NULL
|
|
13
13
|
|
|
14
14
|
@pid_file = nil
|
|
15
15
|
@tracking_pid = true
|
|
@@ -139,7 +139,7 @@ module God
|
|
|
139
139
|
applog(self, :error, "CHROOT directory '#{chroot}' does not exist")
|
|
140
140
|
end
|
|
141
141
|
|
|
142
|
-
unless File.exist?(File.join(chroot,
|
|
142
|
+
unless File.exist?(File.join(chroot, File::NULL))
|
|
143
143
|
valid = false
|
|
144
144
|
applog(self, :error, "CHROOT directory '#{chroot}' does not contain '/dev/null'")
|
|
145
145
|
end
|
|
@@ -253,7 +253,7 @@ module God
|
|
|
253
253
|
$stdout.reopen(w)
|
|
254
254
|
r.close
|
|
255
255
|
pid = self.spawn(command)
|
|
256
|
-
puts pid
|
|
256
|
+
puts pid # send pid back to forker
|
|
257
257
|
exit!(0)
|
|
258
258
|
end
|
|
259
259
|
|
|
@@ -309,9 +309,9 @@ module God
|
|
|
309
309
|
::Process::Sys.setgid(gid_num) if gid_num
|
|
310
310
|
::Process::Sys.setuid(uid_num) if uid
|
|
311
311
|
self.dir ||= '/'
|
|
312
|
-
Dir.chdir
|
|
312
|
+
Dir.chdir dir
|
|
313
313
|
$0 = command
|
|
314
|
-
$stdin.reopen
|
|
314
|
+
$stdin.reopen File::NULL
|
|
315
315
|
if log_cmd
|
|
316
316
|
$stdout.reopen IO.popen(log_cmd, 'a')
|
|
317
317
|
else
|
data/lib/god/timeline.rb
CHANGED
data/lib/god/version.rb
CHANGED
data/lib/god/watch.rb
CHANGED
|
@@ -27,6 +27,7 @@ module God
|
|
|
27
27
|
|
|
28
28
|
# Public: God::Process delegators. See lib/god/process.rb for docs.
|
|
29
29
|
extend Forwardable
|
|
30
|
+
|
|
30
31
|
def_delegators :@process, :name, :uid, :gid, :start, :stop, :restart, :dir,
|
|
31
32
|
:name=, :uid=, :gid=, :start=, :stop=, :restart=,
|
|
32
33
|
:dir=, :pid_file, :pid_file=, :log, :log=,
|
|
@@ -284,7 +285,7 @@ module God
|
|
|
284
285
|
before_items = behaviors
|
|
285
286
|
before_items += [condition] if condition
|
|
286
287
|
before_items.each do |b|
|
|
287
|
-
info = b.send("before_#{action}")
|
|
288
|
+
info = b.send(:"before_#{action}")
|
|
288
289
|
if info
|
|
289
290
|
msg = "#{name} before_#{action}: #{info} (#{b.base_name})"
|
|
290
291
|
applog(self, :info, msg)
|
|
@@ -304,7 +305,7 @@ module God
|
|
|
304
305
|
after_items = behaviors
|
|
305
306
|
after_items += [condition] if condition
|
|
306
307
|
after_items.each do |b|
|
|
307
|
-
info = b.send("after_#{action}")
|
|
308
|
+
info = b.send(:"after_#{action}")
|
|
308
309
|
if info
|
|
309
310
|
msg = "#{name} after_#{action}: #{info} (#{b.base_name})"
|
|
310
311
|
applog(self, :info, msg)
|
data/lib/god.rb
CHANGED
|
@@ -124,7 +124,7 @@ if $load_god
|
|
|
124
124
|
class Module
|
|
125
125
|
def safe_attr_accessor(*args)
|
|
126
126
|
args.each do |arg|
|
|
127
|
-
define_method("#{arg}="
|
|
127
|
+
define_method(:"#{arg}=") do |other|
|
|
128
128
|
abort "God.#{arg} must be set before any Tasks are defined" if !running && inited
|
|
129
129
|
|
|
130
130
|
if running && inited
|
|
@@ -132,11 +132,11 @@ if $load_god
|
|
|
132
132
|
return
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
instance_variable_set("@#{arg}"
|
|
135
|
+
instance_variable_set(:"@#{arg}", other)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
define_method(arg) do
|
|
139
|
-
instance_variable_get("@#{arg}"
|
|
139
|
+
instance_variable_get(:"@#{arg}")
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
142
|
end
|
|
@@ -243,7 +243,7 @@ if $load_god
|
|
|
243
243
|
warn: Logger::WARN,
|
|
244
244
|
error: Logger::ERROR,
|
|
245
245
|
fatal: Logger::FATAL }
|
|
246
|
-
LOG.level = log_level_map[
|
|
246
|
+
LOG.level = log_level_map[log_level]
|
|
247
247
|
|
|
248
248
|
# Init has been executed.
|
|
249
249
|
self.inited = true
|
|
@@ -461,7 +461,7 @@ if $load_god
|
|
|
461
461
|
# Returns true on success, false if all tasks could not be stopped within 10
|
|
462
462
|
# seconds
|
|
463
463
|
def self.stop_all
|
|
464
|
-
watches.sort.each do |_name, w|
|
|
464
|
+
watches.sort.each do |(_name, w)|
|
|
465
465
|
Thread.new do
|
|
466
466
|
w.action(:stop)
|
|
467
467
|
w.unmonitor if w.state != :unmonitored
|
|
@@ -514,8 +514,7 @@ if $load_god
|
|
|
514
514
|
# Returns an Array of String names of the tasks affected.
|
|
515
515
|
def self.signal(name, signal)
|
|
516
516
|
items = watches_by_name(name)
|
|
517
|
-
jobs =
|
|
518
|
-
items.each { |w| jobs << Thread.new { w.signal(signal) } }
|
|
517
|
+
jobs = items.map { |w| Thread.new { w.signal(signal) } }
|
|
519
518
|
jobs.each(&:join)
|
|
520
519
|
items.map(&:name)
|
|
521
520
|
end
|
|
@@ -676,7 +675,7 @@ if $load_god
|
|
|
676
675
|
internal_init
|
|
677
676
|
|
|
678
677
|
# Instantiate server.
|
|
679
|
-
self.server = Socket.new(
|
|
678
|
+
self.server = Socket.new(port, socket_user, socket_group, socket_perms)
|
|
680
679
|
|
|
681
680
|
# Start monitoring any watches set to autostart.
|
|
682
681
|
watches.each_value { |w| w.monitor if w.autostart? }
|
metadata
CHANGED
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: resurrected_god
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom Preston-Werner
|
|
8
8
|
- Kevin Clark
|
|
9
9
|
- Eric Lindvall
|
|
10
10
|
- mishina2228
|
|
11
|
-
autorequire:
|
|
12
11
|
bindir: bin
|
|
13
12
|
cert_chain: []
|
|
14
|
-
date:
|
|
15
|
-
dependencies:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: drb
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
requirements:
|
|
19
|
+
- - "~>"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '2.0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - "~>"
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '2.0'
|
|
29
|
+
- !ruby/object:Gem::Dependency
|
|
30
|
+
name: syslog
|
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - "~>"
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0.1'
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - "~>"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0.1'
|
|
16
43
|
description: An easy to configure, easy to extend monitoring framework written in
|
|
17
44
|
Ruby.
|
|
18
45
|
email:
|
|
@@ -91,8 +118,7 @@ metadata:
|
|
|
91
118
|
changelog_uri: https://github.com/mishina2228/resurrected_god/blob/master/History.md
|
|
92
119
|
homepage_uri: https://github.com/mishina2228/resurrected_god
|
|
93
120
|
rubygems_mfa_required: 'true'
|
|
94
|
-
source_code_uri: https://github.com/mishina2228/resurrected_god/tree/v1.1.
|
|
95
|
-
post_install_message:
|
|
121
|
+
source_code_uri: https://github.com/mishina2228/resurrected_god/tree/v1.1.2
|
|
96
122
|
rdoc_options: []
|
|
97
123
|
require_paths:
|
|
98
124
|
- lib
|
|
@@ -108,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
108
134
|
- !ruby/object:Gem::Version
|
|
109
135
|
version: '0'
|
|
110
136
|
requirements: []
|
|
111
|
-
rubygems_version:
|
|
112
|
-
signing_key:
|
|
137
|
+
rubygems_version: 4.0.3
|
|
113
138
|
specification_version: 4
|
|
114
139
|
summary: Process monitoring framework.
|
|
115
140
|
test_files: []
|