lib/god.rb in god-0.10.1 vs lib/god.rb in god-0.11.0
- old
+ new
@@ -46,31 +46,10 @@
require 'god/conditions/http_response_code'
require 'god/conditions/disk_usage'
require 'god/conditions/complex'
require 'god/conditions/file_mtime'
-require 'god/contact'
-require 'god/contacts/email'
-require 'god/contacts/webhook'
-begin
- require 'god/contacts/twitter'
-rescue LoadError
-end
-begin
- require 'god/contacts/jabber'
-rescue LoadError
-end
-begin
- require 'god/contacts/campfire'
-rescue LoadError
-end
-begin
- require 'god/contacts/prowl'
-rescue LoadError
-end
-
-
require 'god/socket'
require 'god/driver'
require 'god/metric'
require 'god/watch'
@@ -85,10 +64,29 @@
require 'god/cli/version'
require 'god/cli/command'
require 'god/diagnostics'
+CONTACT_DEPS = { }
+CONTACT_LOAD_SUCCESS = { }
+
+def load_contact(name)
+ require "god/contacts/#{name}"
+ CONTACT_LOAD_SUCCESS[name] = true
+rescue LoadError
+ CONTACT_LOAD_SUCCESS[name] = false
+end
+
+require 'god/contact'
+load_contact(:campfire)
+load_contact(:email)
+load_contact(:jabber)
+load_contact(:prowl)
+load_contact(:scout)
+load_contact(:twitter)
+load_contact(:webhook)
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. ext god])
# App wide logging system
LOG = God::Logger.new
@@ -148,11 +146,11 @@
end
end
end
module God
- VERSION = '0.10.1'
+ VERSION = '0.11.0'
LOG_BUFFER_SIZE_DEFAULT = 100
PID_FILE_DIRECTORY_DEFAULTS = ['/var/run/god', '~/.god/pids']
DRB_PORT_DEFAULT = 17165
DRB_ALLOW_DEFAULT = ['127.0.0.1']
LOG_LEVEL_DEFAULT = :info
@@ -349,9 +347,19 @@
# conflicting group name
#
# Returns nothing
def self.contact(kind)
self.internal_init
+
+ # verify contact has been loaded
+ if CONTACT_LOAD_SUCCESS[kind] == false
+ applog(nil, :error, "A required dependency for the #{kind} contact is unavailable.")
+ applog(nil, :error, "Run the following commands to install the dependencies:")
+ CONTACT_DEPS[kind].each do |d|
+ applog(nil, :error, " [sudo] gem install #{d}")
+ end
+ abort
+ end
# create the contact
begin
c = Contact.generate(kind)
rescue NoSuchContactError => e