lib/redis_failover/runner.rb in nogara-redis_failover-0.9.1 vs lib/redis_failover/runner.rb in nogara-redis_failover-0.9.7
- old
+ new
@@ -6,24 +6,22 @@
# @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
+ node_manager = NodeManager.new(options)
+ trap_signals(node_manager)
+ node_manager.start
end
# Traps shutdown signals.
- def self.trap_signals
+ # @param [NodeManager] node_manager the node manager
+ def self.trap_signals(node_manager)
[:INT, :TERM].each do |signal|
trap(signal) do
- Util.logger.info('Shutting down ...')
- @node_manager.shutdown
- @node_manager_thread.join
- exit(0)
+ node_manager.shutdown
end
end
end
+ private_class_method :trap_signals
end
end