diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index bf824f0dbd6106d9c6cb4caffcb32cd16815ce9f..4fa66ffab046317bc880e4b4649091bf4130ce3b 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -321,22 +321,27 @@ void taosAddDataDir(int index, char *v1, int level, int primary) { #ifndef _STORAGE void taosReadDataDirCfg(char *v1, char *v2, char *v3) { - taosAddDataDir(0, tsDataDir, 0, 1); - tstrncpy(tsDiskCfg[0].dir, tsDataDir, TSDB_FILENAME_LEN); + if (tsDiskCfgNum == 1) { + SDiskCfg *cfg = &tsDiskCfg[0]; + uInfo("dataDir:%s, level:%d primary:%d is replaced by %s", cfg->dir, cfg->level, cfg->primary, v1); + } + taosAddDataDir(0, v1, 0, 1); + tsDiskCfgNum = 1; } -#endif void taosPrintDataDirCfg() { for (int i = 0; i < tsDiskCfgNum; ++i) { SDiskCfg *cfg = &tsDiskCfg[i]; - uInfo(" dataDir:%s level:%d primary:%d", cfg->dir, cfg->level, cfg->primary); + uInfo(" dataDir: %s", cfg->dir); } } +#endif static void taosCheckDataDirCfg() { if (tsDiskCfgNum <= 0) { taosAddDataDir(0, tsDataDir, 0, 1); tsDiskCfgNum = 1; + uTrace("dataDir:%s, level:0 primary:1 is configured by default", tsDataDir); } } diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index c4cdf7bee50b736266fd9fc9a4a92351bcd19ea2..16a7e09c993abbab6bb72cc2a20d32f7e900a4bd 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -104,7 +104,7 @@ int32_t dnodeInitSystem() { signal(SIGPIPE, SIG_IGN); if (dnodeCreateDir(tsLogDir) < 0) { - printf("failed to create dir: %s, reason: %s\n", tsLogDir, strerror(errno)); + printf("failed to create log dir: %s, reason: %s\n", tsLogDir, strerror(errno)); return -1; } @@ -186,13 +186,13 @@ static int32_t dnodeInitStorage() { //TODO(dengyihao): no need to init here tdGetMnodeRootDir(tsDataDir, tsMnodeDir); if (dnodeCreateDir(tsMnodeDir) < 0) { - dError("failed to create dir: %s, reason: %s", tsMnodeDir, strerror(errno)); + dError("failed to create mnode dir: %s, reason: %s", tsMnodeDir, strerror(errno)); return -1; } tdGetDnodeRootDir(tsDataDir, tsDnodeDir); if (dnodeCreateDir(tsDnodeDir) < 0) { - dError("failed to create dir: %s, reason: %s", tsDnodeDir, strerror(errno)); + dError("failed to create dnode dir: %s, reason: %s", tsDnodeDir, strerror(errno)); return -1; } @@ -205,13 +205,13 @@ static int32_t dnodeInitStorage() { tdGetVnodeRootDir(dirName, pDisk->dir); if (dnodeCreateDir(dirName) < 0) { - dError("failed to create dir: %s, reason: %s", dirName, strerror(errno)); + dError("failed to create vnode dir: %s, reason: %s", dirName, strerror(errno)); return -1; } tdGetVnodeBackRootDir(dirName, pDisk->dir); if (dnodeCreateDir(dirName) < 0) { - dError("failed to create dir: %s, reason: %s", dirName, strerror(errno)); + dError("failed to create vnode back dir: %s, reason: %s", dirName, strerror(errno)); return -1; } } diff --git a/src/util/src/tconfig.c b/src/util/src/tconfig.c index 80d911f3fc260e74f9643681774deaa1db4c24f9..c705848d5f53f9dffeea79e727e373996d8a608b 100644 --- a/src/util/src/tconfig.c +++ b/src/util/src/tconfig.c @@ -97,32 +97,34 @@ static void taosReadInt16Config(SGlobalCfg *cfg, char *input_value) { } } -static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { +static bool taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { int length = (int)strlen(input_value); char *option = (char *)cfg->ptr; if (length <= 0 || length > cfg->ptrLength) { - uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", - cfg->option, input_value, cfg->ptrLength, option); + uError("config option:%s, input value:%s, length out of range[0, %d], use default value:%s", cfg->option, + input_value, cfg->ptrLength, option); + return false; } else { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { wordexp_t full_path; if (0 != wordexp(input_value, &full_path, 0)) { printf("\nconfig dir: %s wordexp fail! reason:%s\n", input_value, strerror(errno)); wordfree(&full_path); - return; + return false; } - + if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { strcpy(option, full_path.we_wordv[0]); } - + wordfree(&full_path); int code = taosMkDir(option, 0755); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(errno); - uError("config option:%s, input value:%s, directory not exist, create fail:%s", - cfg->option, input_value, strerror(errno)); + uError("config option:%s, input value:%s, directory not exist, create fail:%s", cfg->option, input_value, + strerror(errno)); + return false; } cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE; } else { @@ -130,6 +132,8 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { tsCfgStatusStr[cfg->cfgStatus], option); } } + + return true; } static void taosReadIpStrConfig(SGlobalCfg *cfg, char *input_value) { @@ -225,8 +229,10 @@ static void taosReadConfigOption(const char *option, char *value, char *value2, taosReadDirectoryConfig(cfg, value); break; case TAOS_CFG_VTYPE_DATA_DIRCTORY: - taosReadDirectoryConfig(cfg, value); - taosReadDataDirCfg(value, value2, value3); + if (taosReadDirectoryConfig(cfg, value)) { + taosReadDataDirCfg(value, value2, value3); + } + break; default: uError("config option:%s, input value:%s, can't be recognized", option, value); break; @@ -349,10 +355,11 @@ bool taosReadGlobalCfg() { value[vlen] = 0; paGetToken(value + vlen + 1, &value2, &vlen2); - if (vlen2 != 0) value2[vlen2] = 0; - - paGetToken(value + vlen2 + 1, &value3, &vlen3); - if (vlen3 != 0) value3[vlen3] = 0; + if (vlen2 != 0) { + value2[vlen2] = 0; + paGetToken(value2 + vlen2 + 1, &value3, &vlen3); + if (vlen3 != 0) value3[vlen3] = 0; + } taosReadConfigOption(option, value, value2, value3); }