lib/god.rb in god-0.13.2 vs lib/god.rb in god-0.13.3
- old
+ new
@@ -89,10 +89,11 @@
load_contact(:jabber)
load_contact(:prowl)
load_contact(:scout)
load_contact(:twitter)
load_contact(:webhook)
+load_contact(:airbrake)
$:.unshift File.join(File.dirname(__FILE__), *%w[.. ext god])
# App wide logging system
LOG = God::Logger.new
@@ -154,11 +155,11 @@
end
end
module God
# The String version number for this package.
- VERSION = '0.13.2'
+ VERSION = '0.13.3'
# The Integer number of lines of backlog to keep for the logger.
LOG_BUFFER_SIZE_DEFAULT = 100
# An Array of directory paths to be used as the default PID file directory.
@@ -435,20 +436,27 @@
if contact.group
self.contact_groups[contact.group].delete(contact)
end
end
+ def self.watches_by_name(name)
+ case name
+ when "", nil then self.watches.values.dup
+ else Array(self.watches[name] || self.groups[name]).dup
+ end
+ end
+
# Control the lifecycle of the given task(s).
#
- # name - The String name of a task/group.
+ # name - The String name of a task/group. If empty, invokes command for all tasks.
# command - The String command to run. Valid commands are:
# "start", "monitor", "restart", "stop", "unmonitor", "remove".
#
# Returns an Array of String task names affected by the command.
def self.control(name, command)
# Get the list of items.
- items = Array(self.watches[name] || self.groups[name]).dup
+ items = self.watches_by_name(name)
jobs = []
# Do the command.
case command
@@ -525,10 +533,10 @@
# name - The String name of the task or group.
# signal - The String or integer signal to send. e.g. 'HUP', 9.
#
# Returns an Array of String names of the tasks affected.
def self.signal(name, signal)
- items = Array(self.watches[name] || self.groups[name]).dup
+ items = watches_by_name(name)
jobs = []
items.each { |w| jobs << Thread.new { w.signal(signal) } }
jobs.each { |j| j.join }
items.map { |x| x.name }
end