Skip to content

Commit

Permalink
Merge pull request #24602 from vespa-engine/arnej/add-wouldrun-to-run…
Browse files Browse the repository at this point in the history
…server

add -W option
  • Loading branch information
baldersheim authored Oct 26, 2022
2 parents 65c8d8c + 9d3b2cf commit 357ba1e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion vespalog/src/logger/runserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ int usage(char *prog, int es)
int main(int argc, char *argv[])
{
bool doStop = false;
bool checkWouldRun = false;
int restart = 0;
const char *service = "runserver";
const char *pidfile = "vespa-runserver.pid"; // XXX bad default?
Expand All @@ -350,7 +351,7 @@ int main(int argc, char *argv[])
signal(SIGQUIT, SIG_IGN);

int ch;
while ((ch = getopt(argc, argv, "k:s:r:p:Sh")) != -1) {
while ((ch = getopt(argc, argv, "k:s:r:p:ShW")) != -1) {
switch (ch) {
case 's':
service = optarg;
Expand All @@ -367,6 +368,9 @@ int main(int argc, char *argv[])
case 'k':
killcmd = optarg;
break;
case 'W':
checkWouldRun = true;
break;
default:
return usage(argv[0], ch != 'h');
}
Expand All @@ -383,6 +387,14 @@ int main(int argc, char *argv[])
}

PidFile mypf(pidfile);
if (checkWouldRun) {
if (mypf.anotherRunning()) {
fprintf(stderr, "%s already running with pid %d\n", service, mypf.readPid());
return 1;
} else {
return 0;
}
}
if (doStop) {
if (mypf.anotherRunning()) {
int pid = mypf.readPid();
Expand Down

0 comments on commit 357ba1e

Please sign in to comment.