0
@@ -12,6 +12,7 @@ require 'god/logger'
0
require 'god/system/process'
0
require 'god/dependency_graph'
0
+require 'god/configurable'
0
require 'god/behaviors/clean_pid_file'
0
@@ -28,6 +29,9 @@ require 'god/conditions/lambda'
0
require 'god/conditions/degrading_lambda'
0
require 'god/conditions/flapping'
0
+require 'god/contacts/email'
0
+ # Override abort to exit without executing the at_exit hook
0
@@ -77,7 +89,9 @@ module God
0
@@ -86,6 +100,9 @@ module God
0
+ # yield to the config file
0
+ yield self if block_given?
0
@@ -96,6 +113,8 @@ module God
0
self.pending_watches = []
0
+ self.contact_groups = {}
0
self.log_buffer_size = LOG_BUFFER_SIZE_DEFAULT
0
@@ -103,9 +122,6 @@ module God
0
self.port = DRB_PORT_DEFAULT
0
self.allow = DRB_ALLOW_DEFAULT
0
- # yield to the config file
0
- yield self if block_given?
0
# init has been executed
0
@@ -173,6 +189,48 @@ module God
0
self.groups[watch.group].delete(watch)
0
+ def self.contact(kind)
0
+ # create the condition
0
+ c = Contact.generate(kind)
0
+ rescue NoSuchContactError => e
0
+ # send to block so config can set attributes
0
+ yield(c) if block_given?
0
+ # call prepare on the contact
0
+ # ensure the new contact has a unique name
0
+ if self.contacts[c.name] || self.contact_groups[c.name]
0
+ abort "Contact name '#{c.name}' already used for a Contact or Contact Group"
0
+ # abort if the Contact is invalid, the Contact will have printed
0
+ # out its own error messages by now
0
+ unless Contact.valid?(c) && c.valid?
0
+ abort "Exiting on invalid contact"
0
+ # add to list of contacts
0
+ self.contacts[c.name] = c
0
+ # add to contact group if specified
0
+ # ensure group name hasn't been used for a contact already
0
+ if self.contacts[c.group]
0
+ abort "Contact Group name '#{c.group}' already used for a Contact"
0
+ self.contact_groups[c.group] ||= []
0
+ self.contact_groups[c.group] << c
0
def self.control(name, command)
0
# get the list of watches
Comments
No one has commented yet.