improved "stop" command to try several times.

This commit is contained in:
gardners 2012-04-30 15:34:41 +09:30
parent 808ef53d0f
commit e38854d4c0

View File

@ -616,6 +616,10 @@ int app_server_stop(int argc, const char *const *argv, struct command_line_optio
if (cli_arg(argc, argv, o, "instance path", &thisinstancepath, cli_absolute_path, NULL) == -1) if (cli_arg(argc, argv, o, "instance path", &thisinstancepath, cli_absolute_path, NULL) == -1)
return -1; return -1;
int tries=0;
for(tries=0;tries<3;tries++)
{
int pid=-1; int pid=-1;
int running = servalNodeRunning(&pid); int running = servalNodeRunning(&pid);
if (running>0) { if (running>0) {
@ -658,7 +662,7 @@ int app_server_stop(int argc, const char *const *argv, struct command_line_optio
/* Allow a few seconds for the process to die, and keep an eye on things /* Allow a few seconds for the process to die, and keep an eye on things
while this is happening. */ while this is happening. */
time_t timeout=time(0)+5; time_t timeout=time(0)+2;
while(timeout>time(0)) { while(timeout>time(0)) {
pid=-1; pid=-1;
int running = servalNodeRunning(&pid); int running = servalNodeRunning(&pid);
@ -667,13 +671,12 @@ int app_server_stop(int argc, const char *const *argv, struct command_line_optio
return 0; return 0;
} }
} }
return WHY("I tried to stop it, but it seems that the Serval process is still running.");
} else { } else {
return WHY("Serval process for that instance does not appear to be running."); return WHY("Serval process for that instance does not appear to be running.");
} }
}
return WHY("Not implemented"); return WHY("Tried to stop servald without success");
} }
int app_server_status(int argc, const char *const *argv, struct command_line_option *o) int app_server_status(int argc, const char *const *argv, struct command_line_option *o)