lib/bluth.rb in bluth-0.7.0 vs lib/bluth.rb in bluth-0.7.2

- old
+ new

@@ -33,11 +33,11 @@ class Maeby < Familia::Problem; end # A shutdown request. We burn down the banana stand. class Shutdown < Familia::Problem; end @db = 0 @env = :dev - @queuetimeout = 60 #.seconds + @queuetimeout = 30 #.seconds @handlers = [] @locks = [] @sysinfo = nil @priority = [] @scheduler = nil @@ -64,10 +64,22 @@ @onconnect end def connect instance_eval &onconnect unless onconnect.nil? end + def reconnect! delay=5 + sleep delay + success = begin + Familia.reconnect_all! + (Bluth::Gob.redis.ping.to_s.upcase == 'PONG') + rescue => ex + Familia.info " #{ex.message}" + false + end + Familia.info " reconnected: #{success}" + success + end end def Bluth.clear_locks @locks.each { |lock| Familia.info "Removing lock #{lock}" @@ -171,10 +183,14 @@ raise Bluth::Buster, "No such gob object: #{gobid}" if gob.nil? Bluth::Queue.running << gob.jobid gob.current_queue = :running gob.save end + + rescue Errno::ECONNREFUSED => ex + raise ex + rescue => ex if queue.nil? Familia.info "ERROR: #{ex.message}" else Familia.info "ERROR (#{ex.message}): #{gobid} is an orphan" @@ -253,10 +269,10 @@ module Bluth class Gob < Storable MAX_ATTEMPTS = 3.freeze unless defined?(Gob::MAX_ATTEMPTS) include Familia prefix [:bluth, :gob] - ttl 3600 #.seconds + ttl 60*60*2 # 2 hours index :jobid field :jobid => Gibbler::Digest field :handler => String field :data => Hash field :messages => Array