mirror of https://gitee.com/bigwinds/arangodb
Yet another fix for process shutdown on Unix.
This commit is contained in:
parent
aca081ebaa
commit
6206f91d56
|
@ -356,13 +356,10 @@ launchActions.createSystemColls = function (dispatchers, cmd, isRelaunch) {
|
|||
shutdownActions.startAgent = function (dispatchers, cmd, run) {
|
||||
console.info("Shutting down agent %s", JSON.stringify(run.pid));
|
||||
killExternal(run.pid);
|
||||
statusExternal(run.pid);
|
||||
return {"error": false, "isStartAgent": true};
|
||||
};
|
||||
|
||||
shutdownActions.sendConfiguration = function (dispatchers, cmd, run) {
|
||||
console.info("Waiting for 3 seconds for servers before shutting down agency.");
|
||||
wait(3);
|
||||
return {"error": false, "isSendConfiguration": true};
|
||||
};
|
||||
|
||||
|
@ -379,12 +376,15 @@ shutdownActions.startServers = function (dispatchers, cmd, run) {
|
|||
}
|
||||
download(url,"",{method:"GET", headers: hdrs});
|
||||
}
|
||||
console.info("Waiting 3 seconds for servers to shutdown gracefully...");
|
||||
wait(3);
|
||||
console.info("Waiting 5 seconds for servers to shutdown gracefully...");
|
||||
wait(5);
|
||||
for (i = 0;i < run.pids.length;i++) {
|
||||
console.info("Shutting down %s the hard way...", JSON.stringify(run.pids[i]));
|
||||
killExternal(run.pids[i]);
|
||||
statusExternal(run.pids[i]);
|
||||
var s = statusExternal(run.pids[i]);
|
||||
if (s.status !== "TERMINATED") {
|
||||
console.info("Shutting down %s the hard way...",
|
||||
JSON.stringify(run.pids[i]));
|
||||
killExternal(run.pids[i]);
|
||||
}
|
||||
}
|
||||
return {"error": false, "isStartServers": true};
|
||||
};
|
||||
|
|
|
@ -970,7 +970,12 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
|||
|
||||
#ifndef _WIN32
|
||||
static bool ourKillProcess(TRI_external_t* pid) {
|
||||
return (0 != kill(pid->_pid, SIGTERM));
|
||||
bool success;
|
||||
int loc;
|
||||
success = (0 != kill(pid->_pid, SIGTERM));
|
||||
// And wait for it to avoid a zombie:
|
||||
waitpid(pid->_pid, &loc, WUNTRACED);
|
||||
return success;
|
||||
}
|
||||
#else
|
||||
static bool ourKillProcess(TRI_external_t* pid) {
|
||||
|
@ -1019,6 +1024,8 @@ bool TRI_KillExternalProcess (TRI_external_id_t pid) {
|
|||
TRI_external_t* external;
|
||||
size_t i;
|
||||
bool ok = true;
|
||||
bool success;
|
||||
int loc;
|
||||
|
||||
TRI_LockMutex(&ExternalProcessesLock);
|
||||
|
||||
|
@ -1034,7 +1041,10 @@ bool TRI_KillExternalProcess (TRI_external_id_t pid) {
|
|||
TRI_UnlockMutex(&ExternalProcessesLock);
|
||||
#ifndef _WIN32
|
||||
// Kill just in case:
|
||||
return (0 != kill(pid._pid, SIGTERM));
|
||||
success = (0 != kill(pid._pid, SIGTERM));
|
||||
// And wait for it to avoid a zombie:
|
||||
waitpid(pid._pid, &loc, WUNTRACED);
|
||||
return success;
|
||||
#else
|
||||
return ourKillProcessPID(pid._pid);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue