shm
This commit is contained in:
parent
f9685371a9
commit
c71ec2b7f6
|
@ -14,12 +14,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_DMN_INT_H_
|
#ifndef _TD_DND_EXEC_H_
|
||||||
#define _TD_DMN_INT_H_
|
#define _TD_DND_EXEC_H_
|
||||||
|
|
||||||
#include "tconfig.h"
|
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
|
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
#include "tconfig.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -35,14 +36,14 @@ extern "C" {
|
||||||
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
|
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
|
||||||
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
|
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
void dmnDumpCfg();
|
void dndDumpCfg();
|
||||||
void dmnPrintVersion();
|
void dndPrintVersion();
|
||||||
void dmnGenerateGrant();
|
void dndGenerateGrant();
|
||||||
|
|
||||||
SDnodeObjCfg dmnGetObjCfg();
|
SDnodeObjCfg dndGetObjCfg();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_DMN_INT_H_*/
|
#endif /*_TD_DND_EXEC_H_*/
|
||||||
|
|
|
@ -14,10 +14,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmnInt.h"
|
#include "dndExec.h"
|
||||||
#include "tconfig.h"
|
|
||||||
|
|
||||||
SDnodeObjCfg dmnGetObjCfg() {
|
SDnodeObjCfg dndGetObjCfg() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
SDnodeObjCfg objCfg = {0};
|
SDnodeObjCfg objCfg = {0};
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ SDnodeObjCfg dmnGetObjCfg() {
|
||||||
return objCfg;
|
return objCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmnDumpCfg() {
|
void dndDumpCfg() {
|
||||||
SConfig *pCfg = taosGetCfg();
|
SConfig *pCfg = taosGetCfg();
|
||||||
cfgDumpCfg(pCfg, 0, 1);
|
cfgDumpCfg(pCfg, 0, 1);
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmnInt.h"
|
#include "dndExec.h"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
bool dumpConfig;
|
bool dumpConfig;
|
||||||
|
@ -24,22 +24,22 @@ static struct {
|
||||||
char envFile[PATH_MAX];
|
char envFile[PATH_MAX];
|
||||||
char apolloUrl[PATH_MAX];
|
char apolloUrl[PATH_MAX];
|
||||||
SDnode *pDnode;
|
SDnode *pDnode;
|
||||||
} dmn = {0};
|
} global = {0};
|
||||||
|
|
||||||
static void dmnSigintHandle(int signum, void *info, void *ctx) {
|
static void dndSigintHandle(int signum, void *info, void *ctx) {
|
||||||
dInfo("singal:%d is received", signum);
|
dInfo("singal:%d is received", signum);
|
||||||
dndeHandleEvent(dmn.pDnode, DND_EVENT_STOP);
|
dndeHandleEvent(global.pDnode, DND_EVENT_STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmnSetSignalHandle() {
|
static void dndSetSignalHandle() {
|
||||||
taosSetSignal(SIGTERM, dmnSigintHandle);
|
taosSetSignal(SIGTERM, dndSigintHandle);
|
||||||
taosSetSignal(SIGHUP, dmnSigintHandle);
|
taosSetSignal(SIGHUP, dndSigintHandle);
|
||||||
taosSetSignal(SIGINT, dmnSigintHandle);
|
taosSetSignal(SIGINT, dndSigintHandle);
|
||||||
taosSetSignal(SIGABRT, dmnSigintHandle);
|
taosSetSignal(SIGABRT, dndSigintHandle);
|
||||||
taosSetSignal(SIGBREAK, dmnSigintHandle);
|
taosSetSignal(SIGBREAK, dndSigintHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmnParseOption(int32_t argc, char const *argv[]) {
|
static int32_t dndParseOption(int32_t argc, char const *argv[]) {
|
||||||
for (int32_t i = 1; i < argc; ++i) {
|
for (int32_t i = 1; i < argc; ++i) {
|
||||||
if (strcmp(argv[i], "-c") == 0) {
|
if (strcmp(argv[i], "-c") == 0) {
|
||||||
if (i < argc - 1) {
|
if (i < argc - 1) {
|
||||||
|
@ -53,11 +53,11 @@ static int32_t dmnParseOption(int32_t argc, char const *argv[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-C") == 0) {
|
} else if (strcmp(argv[i], "-C") == 0) {
|
||||||
dmn.dumpConfig = true;
|
global.dumpConfig = true;
|
||||||
} else if (strcmp(argv[i], "-k") == 0) {
|
} else if (strcmp(argv[i], "-k") == 0) {
|
||||||
dmn.generateGrant = true;
|
global.generateGrant = true;
|
||||||
} else if (strcmp(argv[i], "-V") == 0) {
|
} else if (strcmp(argv[i], "-V") == 0) {
|
||||||
dmn.printVersion = true;
|
global.printVersion = true;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,19 +65,20 @@ static int32_t dmnParseOption(int32_t argc, char const *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dmnRunDnode() {
|
static int32_t dndRunDnode() {
|
||||||
if (dndInit() != 0) {
|
if (dndInit() != 0) {
|
||||||
dInfo("failed to initialize dnode environment since %s", terrstr());
|
dInfo("failed to initialize dnode environment since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeObjCfg objCfg = dmnGetObjCfg();
|
SDnodeObjCfg objCfg = dndGetObjCfg();
|
||||||
SDnode *pDnode = dndCreate(&objCfg);
|
SDnode *pDnode = dndCreate(&objCfg);
|
||||||
if (pDnode == NULL) {
|
if (pDnode == NULL) {
|
||||||
dError("failed to to create dnode object since %s", terrstr());
|
dError("failed to to create dnode object since %s", terrstr());
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
dmn.pDnode = pDnode;
|
global.pDnode = pDnode;
|
||||||
|
dndSetSignalHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
dInfo("start the TDengine service");
|
dInfo("start the TDengine service");
|
||||||
|
@ -97,36 +98,36 @@ int main(int argc, char const *argv[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmnParseOption(argc, argv) != 0) {
|
if (dndParseOption(argc, argv) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmn.generateGrant) {
|
if (global.generateGrant) {
|
||||||
dmnGenerateGrant();
|
dndGenerateGrant();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmn.printVersion) {
|
if (global.printVersion) {
|
||||||
dmnPrintVersion();
|
dndPrintVersion();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosCreateLog("taosdlog", 1, configDir, dmn.envFile, dmn.apolloUrl, NULL, 0) != 0) {
|
if (taosCreateLog("taosdlog", 1, configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) {
|
||||||
dError("failed to start TDengine since read log config error");
|
dError("failed to start TDengine since read log config error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosInitCfg(configDir, dmn.envFile, dmn.apolloUrl, NULL, 0) != 0) {
|
if (taosInitCfg(configDir, global.envFile, global.apolloUrl, NULL, 0) != 0) {
|
||||||
dError("failed to start TDengine since read config error");
|
dError("failed to start TDengine since read config error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmn.dumpConfig) {
|
if (global.dumpConfig) {
|
||||||
dmnDumpCfg();
|
dndDumpCfg();
|
||||||
taosCleanupCfg();
|
taosCleanupCfg();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dmnRunDnode();
|
return dndRunDnode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "dmnInt.h"
|
#include "dndExec.h"
|
||||||
|
|
||||||
void dmnGenerateGrant() {
|
void dndGenerateGrant() {
|
||||||
#if 0
|
#if 0
|
||||||
grantParseParameter();
|
grantParseParameter();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmnPrintVersion() {
|
void dndPrintVersion() {
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
char *releaseName = "enterprise";
|
char *releaseName = "enterprise";
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue