Skip to content

Commit 92369c1

Browse files
committedJan 7, 2012
Only update the wre config if stopping or starting really worked. Fix stopping server_starter.
1 parent 2c4fc97 commit 92369c1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎wre/lib/WRE/Starman.pm

+12-3
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,12 @@ sub start {
106106
my $count = 0;
107107
my $success = 0;
108108
my $config = $self->wreConfig;
109-
$config->set("wreMonitor/starmanAdministrativelyDown", 0);
110109
my $host = WRE::Host->new(wreConfig=>$config);
111110
unless ($config->get("starman/port") > 1024 || $host->isPrivilegedUser) {
112111
croak "You are not an administrator on this machine so you cannot start services with ports 1-1024.";
113112
}
114113
my $cmd = "";
115-
#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
114+
#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
116115
$cmd = $config->getRoot("/prereqs/bin/start_server")
117116
. " --pid=" . $config->getRoot("var/run/starman.pid")
118117
. " --status=" . $config->getRoot("var/run/starman.status")
@@ -130,6 +129,9 @@ sub start {
130129
sleep(1);
131130
eval {$success = $self->ping };
132131
}
132+
if ($success) {
133+
$config->set("wreMonitor/starmanAdministrativelyDown", 0);
134+
}
133135
return $success;
134136
}
135137

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

0 commit comments

Comments
 (0)