shm
This commit is contained in:
parent
ea8a336269
commit
8eb99ef6d1
|
@ -21,9 +21,11 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t taosNewProc(char **args);
|
int32_t taosNewProc(char **args);
|
||||||
|
void taosWaitProc(int32_t pid);
|
||||||
|
void taosKillProc(int32_t pid);
|
||||||
|
bool taosProcExist(int32_t pid);
|
||||||
void taosSetProcName(int32_t argc, char **argv, const char *name);
|
void taosSetProcName(int32_t argc, char **argv, const char *name);
|
||||||
void taosSetProcPath(int32_t argc, char **argv);
|
void taosSetProcPath(int32_t argc, char **argv);
|
||||||
bool taosProcExists(int32_t pid);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,17 +255,39 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pDnode->event == DND_EVENT_STOP) {
|
if (pDnode->event == DND_EVENT_STOP) {
|
||||||
dInfo("dnode is about to stop");
|
dInfo("dnode is about to stop");
|
||||||
|
for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
|
if (!pWrapper->required) continue;
|
||||||
|
if (pDnode->ntype == NODE_MAX) continue;
|
||||||
|
|
||||||
|
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
||||||
|
dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId);
|
||||||
|
taosKillProc(pWrapper->procId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
|
if (!pWrapper->required) continue;
|
||||||
|
if (pDnode->ntype == NODE_MAX) continue;
|
||||||
|
|
||||||
|
if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) {
|
||||||
|
dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pWrapper->procId);
|
||||||
|
taosWaitProc(pWrapper->procId);
|
||||||
|
dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
} else {
|
||||||
|
for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) {
|
||||||
|
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
||||||
|
if (!pWrapper->required) continue;
|
||||||
|
if (pDnode->ntype == NODE_MAX) continue;
|
||||||
|
|
||||||
for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) {
|
if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) {
|
||||||
SMgmtWrapper *pWrapper = &pDnode->wrappers[n];
|
dInfo("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId);
|
||||||
if (!pWrapper->required) continue;
|
dndNewProc(pWrapper, n);
|
||||||
if (pDnode->ntype == NODE_MAX) continue;
|
}
|
||||||
|
|
||||||
if (pWrapper->procId <= 0 || !taosProcExists(pWrapper->procId)) {
|
|
||||||
dInfo("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId);
|
|
||||||
dndNewProc(pWrapper, n);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,18 @@ int32_t taosNewProc(char **args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void taosWaitProc(int32_t pid) {
|
||||||
|
int32_t status = 0;
|
||||||
|
waitpid(pid, &status, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void taosKillProc(int32_t pid) { kill(pid, SIGINT); }
|
||||||
|
|
||||||
|
bool taosProcExist(int32_t pid) {
|
||||||
|
int32_t p = getpgid(pid);
|
||||||
|
return p >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
// the length of the new name must be less than the original name to take effect
|
// the length of the new name must be less than the original name to take effect
|
||||||
void taosSetProcName(int32_t argc, char **argv, const char *name) {
|
void taosSetProcName(int32_t argc, char **argv, const char *name) {
|
||||||
prctl(PR_SET_NAME, name);
|
prctl(PR_SET_NAME, name);
|
||||||
|
@ -48,8 +60,3 @@ void taosSetProcName(int32_t argc, char **argv, const char *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosSetProcPath(int32_t argc, char **argv) { tsProcPath = argv[0]; }
|
void taosSetProcPath(int32_t argc, char **argv) { tsProcPath = argv[0]; }
|
||||||
|
|
||||||
bool taosProcExists(int32_t pid) {
|
|
||||||
int32_t p = getpgid(pid);
|
|
||||||
return p >= 0;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue