mojombo-god 0.7.9 → 0.7.10
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.
- data/History.txt +3 -1
- data/Rakefile +1 -1
- data/bin/god +1 -0
- data/lib/god.rb +14 -1
- data/lib/god/cli/command.rb +24 -1
- data/lib/god/process.rb +9 -0
- data/lib/god/task.rb +4 -0
- data/lib/god/watch.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
== 0.7.10 /
|
1
|
+
== 0.7.10 / 2008-11-13
|
2
|
+
* Major Enhancements
|
3
|
+
* Enable sending of arbitrary signals to a task or group via `god signal`
|
2
4
|
* Bug Fixes
|
3
5
|
* setup logging *after* loading a given config file when daemonized.
|
4
6
|
enables logging to the 'God.log_file' specified in a config file. [github.com/jnewland]
|
data/Rakefile
CHANGED
data/bin/god
CHANGED
@@ -33,6 +33,7 @@ begin
|
|
33
33
|
load <file> load a config into a running god
|
34
34
|
log <task name> show realtime log for given task
|
35
35
|
status show status of each task
|
36
|
+
signal <task or group name> <sig> signal all matching tasks
|
36
37
|
quit stop god
|
37
38
|
terminate stop god and all tasks
|
38
39
|
check run self diagnostic
|
data/lib/god.rb
CHANGED
@@ -148,7 +148,7 @@ class Module
|
|
148
148
|
end
|
149
149
|
|
150
150
|
module God
|
151
|
-
VERSION = '0.7.
|
151
|
+
VERSION = '0.7.10'
|
152
152
|
|
153
153
|
LOG_BUFFER_SIZE_DEFAULT = 100
|
154
154
|
PID_FILE_DIRECTORY_DEFAULTS = ['/var/run/god', '~/.god/pids']
|
@@ -481,6 +481,19 @@ module God
|
|
481
481
|
info
|
482
482
|
end
|
483
483
|
|
484
|
+
# Send a signal to each task.
|
485
|
+
# +name+ is the String name of the task or group
|
486
|
+
# +signal+ is the signal to send. e.g. HUP, 9
|
487
|
+
#
|
488
|
+
# Returns String[]:task_names
|
489
|
+
def self.signal(name, signal)
|
490
|
+
items = Array(self.watches[name] || self.groups[name]).dup
|
491
|
+
jobs = []
|
492
|
+
items.each { |w| jobs << Thread.new { w.signal(signal) } }
|
493
|
+
jobs.each { |j| j.join }
|
494
|
+
items.map { |x| x.name }
|
495
|
+
end
|
496
|
+
|
484
497
|
# Log lines for the given task since the specified time.
|
485
498
|
# +watch_name+ is the name of the task (may be abbreviated)
|
486
499
|
# +since+ is the Time since which to report log lines
|
data/lib/god/cli/command.rb
CHANGED
@@ -25,7 +25,7 @@ module God
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def dispatch
|
28
|
-
if %w{load status log quit terminate}.include?(@command)
|
28
|
+
if %w{load status signal log quit terminate}.include?(@command)
|
29
29
|
setup
|
30
30
|
send("#{@command}_command")
|
31
31
|
elsif %w{start stop restart monitor unmonitor remove}.include?(@command)
|
@@ -84,6 +84,29 @@ module God
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
def signal_command
|
88
|
+
# get the name of the watch/group
|
89
|
+
name = @args[1]
|
90
|
+
signal = @args[2]
|
91
|
+
|
92
|
+
puts "Sending signal '#{signal}' to '#{name}'"
|
93
|
+
|
94
|
+
t = Thread.new { loop { sleep(1); STDOUT.print('.'); STDOUT.flush; sleep(1) } }
|
95
|
+
|
96
|
+
watches = @server.signal(name, signal)
|
97
|
+
|
98
|
+
# output response
|
99
|
+
t.kill; STDOUT.puts
|
100
|
+
unless watches.empty?
|
101
|
+
puts 'The following watches were affected:'
|
102
|
+
watches.each do |w|
|
103
|
+
puts ' ' + w
|
104
|
+
end
|
105
|
+
else
|
106
|
+
puts 'No matching task or group'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
87
110
|
def log_command
|
88
111
|
begin
|
89
112
|
Signal.trap('INT') { exit }
|
data/lib/god/process.rb
CHANGED
@@ -159,6 +159,15 @@ module God
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
+
# Send the given signal to this process.
|
163
|
+
#
|
164
|
+
# Returns nothing
|
165
|
+
def signal(sig)
|
166
|
+
sig = sig.to_i if sig.to_i != 0
|
167
|
+
applog(self, :info, "#{self.name} sending signal '#{sig}' to pid #{self.pid}")
|
168
|
+
::Process.kill(sig, self.pid) rescue nil
|
169
|
+
end
|
170
|
+
|
162
171
|
def start!
|
163
172
|
call_action(:start)
|
164
173
|
end
|
data/lib/god/task.rb
CHANGED
data/lib/god/watch.rb
CHANGED
@@ -14,7 +14,7 @@ module God
|
|
14
14
|
def_delegators :@process, :name, :uid, :gid, :start, :stop, :restart,
|
15
15
|
:name=, :uid=, :gid=, :start=, :stop=, :restart=,
|
16
16
|
:pid_file, :pid_file=, :log, :log=, :log_cmd, :log_cmd=, :alive?, :pid,
|
17
|
-
:unix_socket, :unix_socket=, :chroot, :chroot=, :env, :env
|
17
|
+
:unix_socket, :unix_socket=, :chroot, :chroot=, :env, :env=, :signal
|
18
18
|
#
|
19
19
|
def initialize
|
20
20
|
super
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojombo-god
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-13 00:00:00 -08:00
|
13
13
|
default_executable: god
|
14
14
|
dependencies: []
|
15
15
|
|