From 1383e53d4f705dfac5690e74428adb2fab10dd7f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 24 Feb 2022 20:47:15 +0800 Subject: [PATCH] tsim cfg --- source/common/src/tglobal.c | 11 +++++++---- source/dnode/mgmt/daemon/src/dmnMain.c | 2 -- source/os/src/osEnv.c | 12 +++++++++--- source/os/src/osLocale.c | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index a196b1901e..425e1c8d6e 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -217,6 +217,10 @@ static void taosAddClientLogCfg(SConfig *pCfg) { cfgAddInt32(pCfg, "rpcDebugFlag", rpcDebugFlag, 0, 255, 1); cfgAddInt32(pCfg, "tmrDebugFlag", tmrDebugFlag, 0, 255, 1); cfgAddInt32(pCfg, "jniDebugFlag", jniDebugFlag, 0, 255, 1); + cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1); + cfgAddDir(pCfg, "configDir", configDir, 1); + cfgAddDir(pCfg, "scriptDir", configDir, 1); + cfgAddInt32(pCfg, "debugFlag", 0, 0, 255, 1); } static void taosAddServerLogCfg(SConfig *pCfg) { @@ -229,8 +233,6 @@ static void taosAddServerLogCfg(SConfig *pCfg) { cfgAddInt32(pCfg, "tsdbDebugFlag", tsdbDebugFlag, 0, 255, 0); cfgAddInt32(pCfg, "tqDebugFlag", tqDebugFlag, 0, 255, 0); cfgAddInt32(pCfg, "fsDebugFlag", fsDebugFlag, 0, 255, 0); - cfgAddInt32(pCfg, "simDebugFlag", 143, 0, 255, 1); - cfgAddInt32(pCfg, "debugFlag", 0, 0, 255, 1); } static void taosAddClientCfg(SConfig *pCfg) { @@ -246,8 +248,6 @@ static void taosAddClientCfg(SConfig *pCfg) { cfgAddString(pCfg, "secondEp", defaultSecondEp, 1); cfgAddString(pCfg, "fqdn", defaultFqdn, 1); cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056, 1); - cfgAddString(pCfg, "configDir", configDir, 1); - cfgAddString(pCfg, "scriptDir", configDir, 1); cfgAddDir(pCfg, "tempDir", osTempDir(), 1); cfgAddFloat(pCfg, "minimalTempDirGB", 1.0f, 0.001f, 10000000, 1); cfgAddFloat(pCfg, "numOfThreadsPerCore", tsNumOfThreadsPerCore, 0, 10, 1); @@ -300,6 +300,7 @@ static void taosAddServerCfg(SConfig *pCfg) { } static void taosSetClientLogCfg(SConfig *pCfg) { + SConfigItem *pItem = cfgGetItem(pCfg, "logDir"); osSetLogDir(cfgGetItem(pCfg, "logDir")->str); osSetDataReservedSpace(cfgGetItem(pCfg, "minimalLogDirGB")->fval); tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32; @@ -397,6 +398,8 @@ static void taosSetServerCfg(SConfig *pCfg) { int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char *envFile, const char *apolloUrl, bool tsc) { + osInit(); + SConfig *pCfg = cfgInit(); if (pCfg == NULL) return -1; diff --git a/source/dnode/mgmt/daemon/src/dmnMain.c b/source/dnode/mgmt/daemon/src/dmnMain.c index 1a3588bb81..9ce09c0a5d 100644 --- a/source/dnode/mgmt/daemon/src/dmnMain.c +++ b/source/dnode/mgmt/daemon/src/dmnMain.c @@ -97,8 +97,6 @@ int32_t dmnRunDnode() { } int main(int argc, char const *argv[]) { - osInit(); - if (dmnParseOption(argc, argv) != 0) { return -1; } diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index 9a5b251b59..173db8405b 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -92,21 +92,27 @@ void osInit() { strcpy(env.tempDir, tmpDir); } - strcpy(configDir, "C:\\TDengine\\cfg"); + if (configDir[0] == 0) { + strcpy(configDir, "C:\\TDengine\\cfg"); + } strcpy(env.dataDir, "C:\\TDengine\\data"); strcpy(env.logDir, "C:\\TDengine\\log"); strcpy(env.tempDir, "C:\\Windows\\Temp"); strcpy(env.osName, "Windows"); #elif defined(_TD_DARWIN_64) - strcpy(configDir, "/tmp/taosd"); + if (configDir[0] == 0) { + strcpy(configDir, "/tmp/taosd"); + } strcpy(env.dataDir, "/usr/local/var/lib/taos"); strcpy(env.logDir, "/usr/local/var/log/taos"); strcpy(env.tempDir, "/usr/local/etc/taos"); strcpy(env.osName, "Darwin"); #else - strcpy(configDir, "/etc/taos"); + if (configDir[0] == 0) { + strcpy(configDir, "/etc/taos"); + } strcpy(env.dataDir, "/var/lib/taos"); strcpy(env.logDir, "/var/log/taos"); strcpy(env.tempDir, "/tmp"); diff --git a/source/os/src/osLocale.c b/source/os/src/osLocale.c index e5368f945f..47546f7deb 100644 --- a/source/os/src/osLocale.c +++ b/source/os/src/osLocale.c @@ -75,8 +75,8 @@ void taosSetSystemLocale(const char *inLocale, const char *inCharSet) { char *locale = setlocale(LC_CTYPE, inLocale); // default locale or user specified locale is not valid, abort launch - if (inLocale == NULL || strlen(inCharSet) == 0) { - printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale); + if (inLocale == NULL || strlen(inLocale) == 0) { + //printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale); } if (!taosValidateEncodec(inCharSet)) { -- GitLab