Sha256: 98f4da3603092369c4ed4284c236755b6314804cff0bf08f74b0d238c4fb2126

Contents?: true

Size: 842 Bytes

Versions: 7

Compression:

Stored size: 842 Bytes

Contents

module RedisFailover
  # Runner is responsible for bootstrapping the Node Manager.
  class Runner
    # Launches the Node Manager in a background thread.
    #
    # @param [Array] options the command-line options
    # @note this method blocks and does not return until the
    #   Node Manager is gracefully stopped
    def self.run(options)
      options = CLI.parse(options)
      @node_manager = NodeManager.new(options)
      trap_signals
      @node_manager_thread = Thread.new { @node_manager.start }
      @node_manager_thread.join
    end

    # Traps shutdown signals.
    def self.trap_signals
      [:INT, :TERM].each do |signal|
        trap(signal) do
          Util.logger.info('Shutting down ...')
          @node_manager.shutdown
          @node_manager_thread.join
          exit(0)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
nogara-redis_failover-0.9.1 lib/redis_failover/runner.rb
redis_failover-0.9.4 lib/redis_failover/runner.rb
redis_failover-0.9.3 lib/redis_failover/runner.rb
redis_failover-0.9.2 lib/redis_failover/runner.rb
redis_failover-0.9.1 lib/redis_failover/runner.rb
nogara-redis_failover-0.9.0 lib/redis_failover/runner.rb
redis_failover-0.9.0 lib/redis_failover/runner.rb