Class: ProxyMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/locd/proxymachine.rb

Constant Summary collapse

@@max_fast_shutdown_seconds =
1

Class Method Summary collapse

Class Method Details

.fast_shutdown(signal) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/locd/proxymachine.rb', line 18

def self.fast_shutdown(signal)
  EM.stop_server($server) if $server
  # Can't log in trap context (guess you used to be able to?) and this method
  # is only entered from trap contexts, so comment these out to avoid the
  # warning...
  # 
  # 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!
  end
end