lib/proxymachine.rb in fizx-proxymachine-1.2.0 vs lib/proxymachine.rb in fizx-proxymachine-1.3.0
- old
+ new
@@ -5,11 +5,11 @@
require 'proxymachine/client_connection'
require 'proxymachine/server_connection'
require 'proxymachine/callback_server_connection'
-LOGGER = Logger.new(STDOUT)
+$logger = Logger.new(STDOUT)
class ProxyMachine
MAX_FAST_SHUTDOWN_SECONDS = 10
def self.update_procline
@@ -33,11 +33,11 @@
end
def self.decr
@@counter -= 1
if $server.nil?
- LOGGER.info "Waiting for #{@@counter} connections to finish."
+ $logger.info "Waiting for #{@@counter} connections to finish."
end
self.update_procline
EM.stop if $server.nil? and @@counter == 0
@@counter
end
@@ -50,20 +50,20 @@
@@router
end
def self.graceful_shutdown(signal)
EM.stop_server($server) if $server
- LOGGER.info "Received #{signal} signal. No longer accepting new connections."
- LOGGER.info "Waiting for #{ProxyMachine.count} connections to finish."
+ $logger.info "Received #{signal} signal. No longer accepting new connections."
+ $logger.info "Waiting for #{ProxyMachine.count} connections to finish."
$server = nil
EM.stop if ProxyMachine.count == 0
end
def self.fast_shutdown(signal)
EM.stop_server($server) if $server
- LOGGER.info "Received #{signal} signal. No longer accepting new connections."
- LOGGER.info "Maximum time to wait for connections is #{MAX_FAST_SHUTDOWN_SECONDS} seconds."
- LOGGER.info "Waiting for #{ProxyMachine.count} connections to finish."
+ $logger.info "Received #{signal} signal. No longer accepting new connections."
+ $logger.info "Maximum time to wait for connections is #{MAX_FAST_SHUTDOWN_SECONDS} seconds."
+ $logger.info "Waiting for #{ProxyMachine.count} connections to finish."
$server = nil
EM.stop if ProxyMachine.count == 0
Thread.new do
sleep MAX_FAST_SHUTDOWN_SECONDS
exit!
\ No newline at end of file