summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-12-12 14:13:50 +0000
committerSteve Kemp <steve@steve.org.uk>2012-12-12 14:13:50 +0000
commite3d9a6ad6cb2c1463915d356172e5aeb92c4e26f (patch)
tree906b288a0ee1b735d6141d06036aae637b2c9882 /lib/custodian
parent7b79a3ef686fad23bd68a59ce5573699bb059adc (diff)
The dequeuing process passes the settings to the wroker.
Diffstat (limited to 'lib/custodian')
-rw-r--r--lib/custodian/worker.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/custodian/worker.rb b/lib/custodian/worker.rb
index 936c44b..11aa0e6 100644
--- a/lib/custodian/worker.rb
+++ b/lib/custodian/worker.rb
@@ -61,12 +61,18 @@ module Custodian
attr_reader :logger
+ #
+ # The settings from the global configuration file
+ #
+ attr_reader :settings
+
+
#
# Constructor: Connect to the queue
#
- def initialize( server, alerter, logfile )
+ def initialize( server, alerter, logfile, settings )
# Connect to the queue
@queue = Beanstalk::Pool.new([server], "Custodian" )
@@ -77,6 +83,9 @@ module Custodian
# Instantiate the logger.
@logger = Logger.new( logfile, "daily" )
+ # Save the settings
+ @settings = settings
+
# How many times to repeat a failing test
@retry_count=5
@@ -214,10 +223,13 @@ module Custodian
log_message( "Creating alerter: #{alerter}" )
alert = Custodian::AlertFactory.create( alerter, test )
- target = Custodian::Settings.instance().alerter_target( alerter )
+ target = @settings.alerter_target( alerter )
+ alert.set_target( target )
puts "Target for alert is #{target}"
- alert.set_target( target )
+ # give the alerter a reference to the settings object.
+ alert.set_settings( @settings )
+
alert.raise()
end
end
@@ -229,12 +241,15 @@ module Custodian
def do_clear( test )
@alerter.split( "," ).each do |alerter|
log_message( "Creating alerter: #{alerter}" )
- alert = Custodian::AlertFactory.create( alerter, test )
+ alert = Custodian::AlertFactory.create( alerter, test )
- target = Custodian::Settings.instance().alerter_target( alerter )
+ target = @settings.alerter_target( alerter )
+ alert.set_target( target )
puts "Target for alert is #{target}"
- alert.set_target( target )
+ # give the alerter a reference to the settings object.
+ alert.set_settings( @settings )
+
alert.clear()
end
end