-
-
Save anonymous/0e0fc3b5a24cc1c286b506ef3941e597 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Server/Hypnotoad.pm b/lib/Mojo/Server/Hypnotoad.pm | |
index 3a0af10..969fd37 100644 | |
--- a/lib/Mojo/Server/Hypnotoad.pm | |
+++ b/lib/Mojo/Server/Hypnotoad.pm | |
@@ -72,7 +72,8 @@ sub run { | |
$prefork->daemonize if !$ENV{HYPNOTOAD_FOREGROUND} && $ENV{HYPNOTOAD_REV} < 3; | |
# Start accepting connections | |
- local $SIG{USR2} = sub { $self->{upgrade} ||= steady_time }; | |
+ local $SIG{USR2} | |
+ = sub { $prefork->cleanup(0) and ($self->{upgrade} ||= steady_time) }; | |
$prefork->cleanup(1)->run; | |
} | |
@@ -105,6 +106,8 @@ sub _manage { | |
my $log = $prefork->app->log; | |
if ($ENV{HYPNOTOAD_PID} && $ENV{HYPNOTOAD_PID} ne $$) { | |
return unless $prefork->healthy == $prefork->workers; | |
+ unlink $prefork->pid_file; | |
+ $prefork->ensure_pid_file; | |
$log->info("Upgrade successful, stopping $ENV{HYPNOTOAD_PID}"); | |
kill 'QUIT', $ENV{HYPNOTOAD_PID}; | |
} | |
@@ -121,7 +124,7 @@ sub _manage { | |
} | |
# Timeout | |
- kill 'KILL', $self->{new} | |
+ $prefork->cleanup(1) and kill 'KILL', $self->{new} | |
if $self->{upgrade} + $self->upgrade_timeout <= steady_time; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment