summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-26 12:14:43 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-26 12:14:43 +0000
commit0840ba528a225e9be5dd902ee75bd77b9777446e (patch)
tree529ae85a006875cb1bf960de4f69b621729176ce
parentc5ec5f23b9caadc8ef8d9c3233271266c490e23e (diff)
Updated to make the requirement of redis soft, as it will probably be
not used.
-rwxr-xr-xbin/custodian-dequeue2
-rw-r--r--lib/custodian/alerts/redis-state.rb29
2 files changed, 17 insertions, 14 deletions
diff --git a/bin/custodian-dequeue b/bin/custodian-dequeue
index 2d25f0f..efcab32 100755
--- a/bin/custodian-dequeue
+++ b/bin/custodian-dequeue
@@ -1,4 +1,4 @@
-#!/usr/bin/ruby1.8 -Ilib/ -I../lib/
+#!/usr/bin/ruby1.8 -Ilib/ -I../lib/ -rubygems
#
# NAME
# custodian-dequeue - Pull network tests from a queue and execute them in series.
diff --git a/lib/custodian/alerts/redis-state.rb b/lib/custodian/alerts/redis-state.rb
index 1b57b2e..b2243f7 100644
--- a/lib/custodian/alerts/redis-state.rb
+++ b/lib/custodian/alerts/redis-state.rb
@@ -1,5 +1,3 @@
-
-
#
# The redis-alerter.
#
@@ -14,7 +12,7 @@ module Custodian
module Alerter
- class AlertRedis < AlertFactory
+ class RedisAlert < AlertFactory
#
# The test this alerter cares about
@@ -26,22 +24,25 @@ module Custodian
#
attr_reader :redis
+ attr_reader :available
#
# Constructor - save the test-object away & instantiate
# the redis connection.
#
def initialize( obj )
-
- begin
- require 'rubygems'
- require 'redis'
- rescue LoadError
- raise "ERROR Loading redis rubygem!"
- end
-
- @test = obj
- @redis = Redis.new
+ @available = true
+
+ begin
+ require 'rubygems'
+ require 'redis'
+ rescue
+ puts "LOADING redis failed"
+ @available = false
+ end
+
+ @test = obj
+ @redis = Redis.new( ) if ( @available )
end
@@ -50,6 +51,7 @@ module Custodian
# Store an alert in redis
#
def raise
+ return if ( ! @available )
# hostname + test-type
host = @test.target
@@ -69,6 +71,7 @@ module Custodian
# Clear an alert in redis
#
def clear
+ return if ( ! @available )
# hostname + test-type
host = @test.target