Skip to content

Commit

Permalink
pass two arguments to exec
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 24, 2014
1 parent e17d1c9 commit 890aa77
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -40,14 +40,15 @@ sub run {
_exit('Hypnotoad not available for Windows.') if $^O eq 'MSWin32';

# Remember executable and application for later
$ENV{HYPNOTOAD_EXE} ||= "$^X $0";
$ENV{HYPNOTOAD_EXE} ||= $0;
$0 = $ENV{HYPNOTOAD_APP} ||= abs_path $app;

# This is a production server
$ENV{MOJO_MODE} ||= 'production';

# Clean start (to make sure everything works)
die "Can't exec: $!" if !$ENV{HYPNOTOAD_REV}++ && !exec $ENV{HYPNOTOAD_EXE};
die "Can't exec: $!"
if !$ENV{HYPNOTOAD_REV}++ && !exec $^X, $ENV{HYPNOTOAD_EXE};

# Preload application and configure server
my $prefork = $self->prefork->cleanup(0);
Expand Down Expand Up @@ -107,7 +108,7 @@ sub _manage {
unless ($self->{new}) {
$log->info('Starting zero downtime software upgrade.');
die "Can't fork: $!" unless defined(my $pid = $self->{new} = fork);
exec($ENV{HYPNOTOAD_EXE}) or die("Can't exec: $!") unless $pid;
exec $^X, $ENV{HYPNOTOAD_EXE} or die "Can't exec: $!" unless $pid;
}

# Timeout
Expand Down

0 comments on commit 890aa77

Please sign in to comment.