set signal
This commit is contained in:
parent
dd94e2da5a
commit
4dc47f7b8e
|
@ -51,7 +51,7 @@ extern int32_t tsCompatibleModel;
|
||||||
extern bool tsEnableSlaveQuery;
|
extern bool tsEnableSlaveQuery;
|
||||||
extern bool tsPrintAuth;
|
extern bool tsPrintAuth;
|
||||||
extern int64_t tsTickPerDay[3];
|
extern int64_t tsTickPerDay[3];
|
||||||
extern int32_t tsMultiProcess;
|
extern bool tsMultiProcess;
|
||||||
|
|
||||||
// monitor
|
// monitor
|
||||||
extern bool tsEnableMonitor;
|
extern bool tsEnableMonitor;
|
||||||
|
|
|
@ -48,9 +48,10 @@ typedef struct {
|
||||||
char secondEp[TSDB_EP_LEN];
|
char secondEp[TSDB_EP_LEN];
|
||||||
SDiskCfg *pDisks;
|
SDiskCfg *pDisks;
|
||||||
int32_t numOfDisks;
|
int32_t numOfDisks;
|
||||||
|
int8_t ntype;
|
||||||
} SDnodeOpt;
|
} SDnodeOpt;
|
||||||
|
|
||||||
typedef enum { DND_EVENT_START, DND_EVENT_STOP = 1, DND_EVENT_RELOAD } EDndEvent;
|
typedef enum { DND_EVENT_START, DND_EVENT_STOP = 1, DND_EVENT_CHILD } EDndEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize and start the dnode.
|
* @brief Initialize and start the dnode.
|
||||||
|
|
|
@ -45,7 +45,7 @@ float tsRatioOfQueryCores = 1.0f;
|
||||||
int32_t tsMaxBinaryDisplayWidth = 30;
|
int32_t tsMaxBinaryDisplayWidth = 30;
|
||||||
bool tsEnableSlaveQuery = 1;
|
bool tsEnableSlaveQuery = 1;
|
||||||
bool tsPrintAuth = 0;
|
bool tsPrintAuth = 0;
|
||||||
int32_t tsMultiProcess = 0;
|
bool tsMultiProcess = 0;
|
||||||
|
|
||||||
// monitor
|
// monitor
|
||||||
bool tsEnableMonitor = 1;
|
bool tsEnableMonitor = 1;
|
||||||
|
@ -347,7 +347,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "slaveQuery", tsEnableSlaveQuery, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "slaveQuery", tsEnableSlaveQuery, 0) != 0) return -1;
|
||||||
if (cfgAddBool(pCfg, "deadLockKillQuery", tsDeadLockKillQuery, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "deadLockKillQuery", tsDeadLockKillQuery, 0) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "multiProcess", tsMultiProcess, 0) != 0) return -1;
|
||||||
|
|
||||||
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 360000, 0) != 0) return -1;
|
if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 360000, 0) != 0) return -1;
|
||||||
|
@ -466,7 +466,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
|
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
|
||||||
tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval;
|
tsEnableSlaveQuery = cfgGetItem(pCfg, "slaveQuery")->bval;
|
||||||
tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->bval;
|
tsDeadLockKillQuery = cfgGetItem(pCfg, "deadLockKillQuery")->bval;
|
||||||
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->i32;
|
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
|
||||||
|
|
||||||
tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval;
|
tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval;
|
||||||
tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32;
|
tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32;
|
||||||
|
|
|
@ -29,7 +29,7 @@ static struct {
|
||||||
ENodeType ntype;
|
ENodeType ntype;
|
||||||
} global = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dndSigintHandle(int signum, void *info, void *ctx) {
|
static void dndStopDnode(int signum, void *info, void *ctx) {
|
||||||
dInfo("signal:%d is received", signum);
|
dInfo("signal:%d is received", signum);
|
||||||
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode);
|
||||||
if (pDnode != NULL) {
|
if (pDnode != NULL) {
|
||||||
|
@ -37,12 +37,29 @@ static void dndSigintHandle(int signum, void *info, void *ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dndHandleChild(int signum, void *info, void *ctx) {
|
||||||
|
dInfo("signal:%d is received", signum);
|
||||||
|
dndHandleEvent(global.pDnode, DND_EVENT_CHILD);
|
||||||
|
}
|
||||||
|
|
||||||
static void dndSetSignalHandle() {
|
static void dndSetSignalHandle() {
|
||||||
taosSetSignal(SIGTERM, dndSigintHandle);
|
taosSetSignal(SIGTERM, dndStopDnode);
|
||||||
taosSetSignal(SIGHUP, dndSigintHandle);
|
taosSetSignal(SIGHUP, dndStopDnode);
|
||||||
taosSetSignal(SIGINT, dndSigintHandle);
|
taosSetSignal(SIGINT, dndStopDnode);
|
||||||
taosSetSignal(SIGABRT, dndSigintHandle);
|
taosSetSignal(SIGABRT, dndStopDnode);
|
||||||
taosSetSignal(SIGBREAK, dndSigintHandle);
|
taosSetSignal(SIGBREAK, dndStopDnode);
|
||||||
|
|
||||||
|
if (!tsMultiProcess) {
|
||||||
|
// Set the single process signal
|
||||||
|
} else if (global.ntype == DNODE) {
|
||||||
|
// Set the parent process signal
|
||||||
|
// When the child process exits, the parent process receives a signal
|
||||||
|
taosSetSignal(SIGCHLD, dndHandleChild);
|
||||||
|
} else {
|
||||||
|
// Set child process signal
|
||||||
|
// When the parent process exits, the child process will receive the SIGKILL signal
|
||||||
|
prctl(PR_SET_PDEATHSIG, SIGKILL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
static int32_t dndParseArgs(int32_t argc, char const *argv[]) {
|
||||||
|
@ -111,6 +128,7 @@ static SDnodeOpt dndGetOpt() {
|
||||||
snprintf(option.localEp, sizeof(option.localEp), "%s:%u", option.localFqdn, option.serverPort);
|
snprintf(option.localEp, sizeof(option.localEp), "%s:%u", option.localFqdn, option.serverPort);
|
||||||
option.pDisks = tsDiskCfg;
|
option.pDisks = tsDiskCfg;
|
||||||
option.numOfDisks = tsDiskCfgNum;
|
option.numOfDisks = tsDiskCfgNum;
|
||||||
|
option.ntype = global.ntype;
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +139,7 @@ static int32_t dndInitLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dndSetProcName(char **argv) {
|
static void dndSetProcName(char **argv) {
|
||||||
if (global.ntype != 0) {
|
if (global.ntype != DNODE) {
|
||||||
const char *name = dndNodeProcStr(global.ntype);
|
const char *name = dndNodeProcStr(global.ntype);
|
||||||
prctl(PR_SET_NAME, name);
|
prctl(PR_SET_NAME, name);
|
||||||
strcpy(argv[0], name);
|
strcpy(argv[0], name);
|
||||||
|
|
|
@ -123,6 +123,7 @@ typedef struct SDnode {
|
||||||
int32_t numOfDisks;
|
int32_t numOfDisks;
|
||||||
uint16_t serverPort;
|
uint16_t serverPort;
|
||||||
bool dropped;
|
bool dropped;
|
||||||
|
ENodeType ntype;
|
||||||
EDndStatus status;
|
EDndStatus status;
|
||||||
EDndEvent event;
|
EDndEvent event;
|
||||||
SStartupReq startup;
|
SStartupReq startup;
|
||||||
|
|
|
@ -259,7 +259,7 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dndRun(SDnode *pDnode) {
|
int32_t dndRun(SDnode *pDnode) {
|
||||||
if (tsMultiProcess == 0) {
|
if (!tsMultiProcess) {
|
||||||
if (dndRunInSingleProcess(pDnode) != 0) {
|
if (dndRunInSingleProcess(pDnode) != 0) {
|
||||||
dError("failed to run dnode in single process mode since %s", terrstr());
|
dError("failed to run dnode in single process mode since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -26,6 +26,7 @@ static int32_t dndInitMemory(SDnode *pDnode, const SDnodeOpt *pOption) {
|
||||||
pDnode->secondEp = strdup(pOption->secondEp);
|
pDnode->secondEp = strdup(pOption->secondEp);
|
||||||
pDnode->pDisks = pOption->pDisks;
|
pDnode->pDisks = pOption->pDisks;
|
||||||
pDnode->numOfDisks = pOption->numOfDisks;
|
pDnode->numOfDisks = pOption->numOfDisks;
|
||||||
|
pDnode->ntype = pOption->ntype;
|
||||||
pDnode->rebootTime = taosGetTimestampMs();
|
pDnode->rebootTime = taosGetTimestampMs();
|
||||||
|
|
||||||
if (pDnode->dataDir == NULL || pDnode->localEp == NULL || pDnode->localFqdn == NULL || pDnode->firstEp == NULL ||
|
if (pDnode->dataDir == NULL || pDnode->localEp == NULL || pDnode->localFqdn == NULL || pDnode->firstEp == NULL ||
|
||||||
|
|
Loading…
Reference in New Issue