Skip to content

Commit

Permalink
improved Hypnotoad error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 31, 2012
1 parent 8260910 commit 61beade
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@
This file documents the revision history for Perl extension Mojolicious.

2.71 2012-03-31
- Improved Hypnotoad error handling.
- Improved documentation.
- Improved tests.

Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -59,7 +59,8 @@ sub run {
$0 = $ENV{HYPNOTOAD_APP};

# Clean start
exec $ENV{HYPNOTOAD_EXE} unless $ENV{HYPNOTOAD_REV}++;
croak "Can't exec: $!"
if !$ENV{HYPNOTOAD_REV}++ && !exec $ENV{HYPNOTOAD_EXE};

# Preload application and configure server
my $daemon = $self->{daemon} = Mojo::Server::Daemon->new;
Expand Down Expand Up @@ -224,8 +225,8 @@ sub _manage {
# Fresh start
unless ($self->{new}) {
$self->{log}->info('Starting zero downtime software upgrade.');
croak "Can't fork: $!" unless defined(my $pid = fork);
$self->{new} = $pid ? $pid : exec($ENV{HYPNOTOAD_EXE});
croak "Can't fork: $!" unless defined(my $pid = $self->{new} = fork);
exec($ENV{HYPNOTOAD_EXE}) or croak("Can't exec: $!") unless $pid;
}

# Timeout
Expand Down

0 comments on commit 61beade

Please sign in to comment.