lib/flapjack/gateways/pagerduty.rb in flapjack-0.7.20 vs lib/flapjack/gateways/pagerduty.rb in flapjack-0.7.21

- old
+ new

@@ -18,22 +18,26 @@ SEM_PAGERDUTY_ACKS_RUNNING = 'sem_pagerduty_acks_running' def initialize(opts = {}) @config = opts[:config] @logger = opts[:logger] - @redis_config = opts[:redis_config] - @redis = Flapjack::RedisPool.new(:config => @redis_config, :size => 2) # first will block + @redis_config = opts[:redis_config] || {} + @redis = Flapjack::RedisPool.new(:config => @redis_config, :size => 2) @logger.debug("New Pagerduty pikelet with the following options: #{@config.inspect}") @pagerduty_acks_started = nil super() end def stop @logger.info("stopping") @should_quit = true - @redis.rpush(@config['queue'], Oj.dump('notification_type' => 'shutdown')) + + redis_uri = @redis_config[:path] || + "redis://#{@redis_config[:host] || '127.0.0.1'}:#{@redis_config[:port] || '6379'}/#{@redis_config[:db] || '0'}" + shutdown_redis = EM::Hiredis.connect(redis_uri) + shutdown_redis.rpush(@config['queue'], Oj.dump('notification_type' => 'shutdown')) end def start @logger.info("starting") while not test_pagerduty_connection and not @should_quit do