mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Keep jruby daemon mode from retrying on a hot restart
This commit is contained in:
parent
8faea06e44
commit
f4682fb9d6
2 changed files with 26 additions and 5 deletions
|
@ -21,15 +21,34 @@ module Puma
|
|||
raise SystemCallError.new(FFI.errno)
|
||||
end
|
||||
|
||||
PermKey = 'PUMA_DAEMON_PERM'
|
||||
RestartKey = 'PUMA_DAEMON_RESTART'
|
||||
|
||||
# Called to tell things "Your now always in daemon mode,
|
||||
# don't try to reenter it."
|
||||
#
|
||||
def self.perm_daemonize
|
||||
ENV[PermKey] = "1"
|
||||
end
|
||||
|
||||
def self.daemon?
|
||||
ENV.key? 'PUMA_DAEMON_RESTART'
|
||||
ENV.key?(PermKey) || ENV.key?(RestartKey)
|
||||
end
|
||||
|
||||
def self.daemon_init
|
||||
return false unless ENV.key? 'PUMA_DAEMON_RESTART'
|
||||
return true if ENV.key?(PermKey)
|
||||
|
||||
master = ENV['PUMA_DAEMON_RESTART']
|
||||
Process.kill "SIGUSR2", master.to_i
|
||||
return false unless ENV.key? RestartKey
|
||||
|
||||
master = ENV[RestartKey]
|
||||
|
||||
# In case the master disappears early
|
||||
begin
|
||||
Process.kill "SIGUSR2", master.to_i
|
||||
rescue SystemCallError => e
|
||||
end
|
||||
|
||||
ENV[RestartKey] = ""
|
||||
|
||||
setsid
|
||||
|
||||
|
|
|
@ -47,7 +47,9 @@ module Puma
|
|||
output_header "single"
|
||||
|
||||
if jruby_daemon?
|
||||
unless already_daemon
|
||||
if already_daemon
|
||||
JRubyRestart.perm_daemonize
|
||||
else
|
||||
pid = nil
|
||||
|
||||
Signal.trap "SIGUSR2" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue