Skip to content

Commit

Permalink
Only update the wre config if stopping or starting really worked. Fix…
Browse files Browse the repository at this point in the history
… stopping server_starter.
  • Loading branch information
perlDreamer committed Jan 7, 2012
1 parent 2c4fc97 commit 92369c1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions wre/lib/WRE/Starman.pm
Expand Up @@ -106,13 +106,12 @@ sub start {
my $count = 0;
my $success = 0;
my $config = $self->wreConfig;
$config->set("wreMonitor/starmanAdministrativelyDown", 0);
my $host = WRE::Host->new(wreConfig=>$config);
unless ($config->get("starman/port") > 1024 || $host->isPrivilegedUser) {
croak "You are not an administrator on this machine so you cannot start services with ports 1-1024.";
}
my $cmd = "";
#start_server --pid-file=/data/wre/var/run/starman.pid --port=8081 --status=/data/wre/var/run/starman.status starman --preload-app=/data/WebGUI/app.psgi
#start_server --pid-file=/data/wre/var/run/starman.pid --port=8081 --status=/data/wre/var/run/starman.status -- starman --preload-app /data/WebGUI/app.psgi
$cmd = $config->getRoot("/prereqs/bin/start_server")
. " --pid=" . $config->getRoot("var/run/starman.pid")
. " --status=" . $config->getRoot("var/run/starman.status")
Expand All @@ -130,6 +129,9 @@ sub start {
sleep(1);
eval {$success = $self->ping };
}
if ($success) {
$config->set("wreMonitor/starmanAdministrativelyDown", 0);
}
return $success;
}

Expand All @@ -153,11 +155,18 @@ sub stop {
unless ($config->get("starman/port") > 1024 || $host->isPrivilegedUser) {
croak "You are not an administrator on this machine so you cannot stop services with ports 1-1024.";
}
#kill "TERM", 0;
open my $pid_file, $config->getRoot('var/run/starman.pid') or
croak "Unable open PID file ".$config->getRoot('var/run/starman.pid')." for reading $!\n";
my $pid = do { local $/; <$pid_file> };
close $pid_file;
kill "TERM", $pid;
while ($count++ < 10 && $success) {
sleep(1);
eval { $success = $self->ping };
}
if ($success) {
$config->set("wreMonitor/starmanAdministrativelyDown", 1);
}
return $success;
}

Expand Down

0 comments on commit 92369c1

Please sign in to comment.