Sha256: 3bcefc3c0e391389192c3aac61235e8741aeaa14b37f77db5ff4025b0d060097

Contents?: true

Size: 954 Bytes

Versions: 5

Compression:

Stored size: 954 Bytes

Contents

module RedisFailover
  # Runner is responsible for bootstrapping the redis failover server.
  class Runner
    def self.run(options)
      options = CLI.parse(options)
      Util.logger.info("Redis Failover Server starting on port #{options[:port]}")
      Server.set(:port, options[:port])
      @node_manager = NodeManager.new(options)
      server_thread = Thread.new { Server.run! { |server| trap_signals } }
      node_manager_thread = Thread.new { @node_manager.start }
      [server_thread, node_manager_thread].each(&: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

5 entries across 5 versions & 1 rubygems

Version Path
redis_failover-0.4.0 lib/redis_failover/runner.rb
redis_failover-0.3.0 lib/redis_failover/runner.rb
redis_failover-0.2.0 lib/redis_failover/runner.rb
redis_failover-0.1.1 lib/redis_failover/runner.rb
redis_failover-0.1.0 lib/redis_failover/runner.rb