Sha256: 384aaaf1daacc09310943a61ec357e526a0b3078e7e18bcb0b81e312e809748e

Contents?: true

Size: 847 Bytes

Versions: 2

Compression:

Stored size: 847 Bytes

Contents

module RedisFailover
  # Runner is responsible for bootstrapping the redis Node Manager.
  class Runner
    def self.run(options)
      options = CLI.parse(options)
      @node_manager = NodeManager.new(options)
      trap_signals
      node_manager_thread = Thread.new { @node_manager.start }
      Util.logger.info("Redis Node Manager v#{VERSION} successfully started (#{RUBY_DESCRIPTION})")
      node_manager_thread.join
    end

    def self.node_manager
      @node_manager
    end

    def self.trap_signals
      [:INT, :TERM].each do |signal|
        previous_signal = trap(signal) do
          Util.logger.info('Shutting down ...')
          if previous_signal && previous_signal.respond_to?(:call)
            previous_signal.call
          end
          @node_manager.shutdown
          exit(0)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
redis_failover-0.5.4 lib/redis_failover/runner.rb
redis_failover-0.5.3 lib/redis_failover/runner.rb