sim config
This commit is contained in:
parent
42c100df2d
commit
4e573e41e0
|
@ -22,8 +22,6 @@ extern "C" {
|
||||||
|
|
||||||
extern char tsOsName[];
|
extern char tsOsName[];
|
||||||
extern char tsDataDir[];
|
extern char tsDataDir[];
|
||||||
extern char tsLogDir[];
|
|
||||||
extern char tsScriptDir[];
|
|
||||||
extern char configDir[];
|
extern char configDir[];
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// log
|
extern char tsLogDir[];
|
||||||
|
extern bool tsLogInited;
|
||||||
extern bool tsAsyncLog;
|
extern bool tsAsyncLog;
|
||||||
extern int32_t tsNumOfLogLines;
|
extern int32_t tsNumOfLogLines;
|
||||||
extern int32_t tsLogKeepDays;
|
extern int32_t tsLogKeepDays;
|
||||||
|
@ -41,20 +42,21 @@ extern int32_t tsdbDebugFlag;
|
||||||
extern int32_t tqDebugFlag;
|
extern int32_t tqDebugFlag;
|
||||||
extern int32_t fsDebugFlag;
|
extern int32_t fsDebugFlag;
|
||||||
|
|
||||||
#define DEBUG_FATAL 1U
|
#define DEBUG_FATAL 1U
|
||||||
#define DEBUG_ERROR DEBUG_FATAL
|
#define DEBUG_ERROR DEBUG_FATAL
|
||||||
#define DEBUG_WARN 2U
|
#define DEBUG_WARN 2U
|
||||||
#define DEBUG_INFO DEBUG_WARN
|
#define DEBUG_INFO DEBUG_WARN
|
||||||
#define DEBUG_DEBUG 4U
|
#define DEBUG_DEBUG 4U
|
||||||
#define DEBUG_TRACE 8U
|
#define DEBUG_TRACE 8U
|
||||||
#define DEBUG_DUMP 16U
|
#define DEBUG_DUMP 16U
|
||||||
|
|
||||||
#define DEBUG_SCREEN 64U
|
#define DEBUG_SCREEN 64U
|
||||||
#define DEBUG_FILE 128U
|
#define DEBUG_FILE 128U
|
||||||
|
|
||||||
int32_t taosInitLog(const char *logName, int32_t maxFiles);
|
int32_t taosInitLog(const char *logName, int32_t maxFiles);
|
||||||
void taosCloseLog();
|
void taosCloseLog();
|
||||||
void taosResetLog();
|
void taosResetLog();
|
||||||
|
void taosSetAllDebugFlag(int32_t flag);
|
||||||
|
void taosDumpData(unsigned char *msg, int32_t len);
|
||||||
|
|
||||||
void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...)
|
void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...)
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
@ -68,11 +70,6 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
void taosDumpData(unsigned char *msg, int32_t len);
|
|
||||||
|
|
||||||
|
|
||||||
void taosSetAllDebugFlag(int32_t flag);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -83,6 +83,8 @@ static int32_t tscSetLogCfg(SConfig *pCfg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
int32_t tscInitLog(const char *cfgDir, const char *envFile, const char *apolloUrl) {
|
||||||
|
if (tsLogInited) return 0;
|
||||||
|
|
||||||
SConfig *pCfg = cfgInit();
|
SConfig *pCfg = cfgInit();
|
||||||
if (pCfg == NULL) return -1;
|
if (pCfg == NULL) return -1;
|
||||||
|
|
||||||
|
@ -111,6 +113,7 @@ int32_t tscInitLog(const char *cfgDir, const char *envFile, const char *apolloUr
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfgDumpCfg(pCfg);
|
||||||
cfgCleanup(pCfg);
|
cfgCleanup(pCfg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +154,7 @@ static int32_t tscAddCfg(SConfig *pCfg) {
|
||||||
if (cfgAddInt32(pCfg, "numOfCores", 1, 1, 100000) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfCores", 1, 1, 100000) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "numOfCommitThreads", 4, 1, 1000) != 0) return -1;
|
if (cfgAddInt32(pCfg, "numOfCommitThreads", 4, 1, 1000) != 0) return -1;
|
||||||
// if (cfgAddBool(pCfg, "telemetryReporting", 0) != 0) return -1;
|
// if (cfgAddBool(pCfg, "telemetryReporting", 0) != 0) return -1;
|
||||||
// if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1;
|
if (cfgAddBool(pCfg, "enableCoreFile", 0) != 0) return -1;
|
||||||
// if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536) != 0) return -1;
|
// if (cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536) != 0) return -1;
|
||||||
if (cfgAddInt32(pCfg, "statusInterval", 1, 1, 30) != 0) return -1;
|
if (cfgAddInt32(pCfg, "statusInterval", 1, 1, 30) != 0) return -1;
|
||||||
if (cfgAddFloat(pCfg, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1;
|
if (cfgAddFloat(pCfg, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1;
|
||||||
|
@ -174,12 +177,6 @@ SConfig *tscInitCfgImp(const char *cfgDir, const char *envFile, const char *apol
|
||||||
SConfig *pCfg = cfgInit();
|
SConfig *pCfg = cfgInit();
|
||||||
if (pCfg == NULL) return NULL;
|
if (pCfg == NULL) return NULL;
|
||||||
|
|
||||||
if (tscAddLogCfg(pCfg) != 0) {
|
|
||||||
uError("failed to add log cfg since %s", terrstr());
|
|
||||||
cfgCleanup(pCfg);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tscAddCfg(pCfg) != 0) {
|
if (tscAddCfg(pCfg) != 0) {
|
||||||
uError("failed to init tsc cfg since %s", terrstr());
|
uError("failed to init tsc cfg since %s", terrstr());
|
||||||
cfgCleanup(pCfg);
|
cfgCleanup(pCfg);
|
||||||
|
|
|
@ -280,15 +280,6 @@ static void doInitGlobalConfig(void) {
|
||||||
#if 0
|
#if 0
|
||||||
SGlobalCfg cfg = {0};
|
SGlobalCfg cfg = {0};
|
||||||
|
|
||||||
cfg.option = "scriptDir";
|
|
||||||
cfg.ptr = tsScriptDir;
|
|
||||||
cfg.valType = TAOS_CFG_VTYPE_DIRECTORY;
|
|
||||||
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
|
|
||||||
cfg.minValue = 0;
|
|
||||||
cfg.maxValue = 0;
|
|
||||||
cfg.ptrLength = TSDB_FILENAME_LEN;
|
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
|
||||||
taosAddConfigOption(cfg);
|
|
||||||
|
|
||||||
cfg.option = "dataDir";
|
cfg.option = "dataDir";
|
||||||
cfg.ptr = tsDataDir;
|
cfg.ptr = tsDataDir;
|
||||||
|
|
|
@ -202,7 +202,7 @@ SDnodeObjCfg dmnGetObjCfg(SConfig *pCfg) {
|
||||||
tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp));
|
tstrncpy(objCfg.firstEp, cfgGetItem(pCfg, "firstEp")->str, sizeof(objCfg.firstEp));
|
||||||
tstrncpy(objCfg.secondEp, cfgGetItem(pCfg, "secondEp")->str, sizeof(objCfg.firstEp));
|
tstrncpy(objCfg.secondEp, cfgGetItem(pCfg, "secondEp")->str, sizeof(objCfg.firstEp));
|
||||||
objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
objCfg.serverPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||||
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn, cfgGetItem));
|
tstrncpy(objCfg.localFqdn, cfgGetItem(pCfg, "fqdn")->str, sizeof(objCfg.localFqdn));
|
||||||
snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort);
|
snprintf(objCfg.localEp, sizeof(objCfg.localEp), "%s:%u", objCfg.localFqdn, objCfg.serverPort);
|
||||||
return objCfg;
|
return objCfg;
|
||||||
}
|
}
|
|
@ -15,11 +15,14 @@
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "cfgInt.h"
|
#include "cfgInt.h"
|
||||||
#include "tmsg.h"
|
|
||||||
#include "tep.h"
|
#include "tep.h"
|
||||||
#include "tlocale.h"
|
#include "tlocale.h"
|
||||||
|
#include "tmsg.h"
|
||||||
#include "ttimezone.h"
|
#include "ttimezone.h"
|
||||||
|
|
||||||
|
#define CFG_NAME_PRINT_LEN 22
|
||||||
|
#define CFG_SRC_PRINT_LEN 12
|
||||||
|
|
||||||
SConfig *cfgInit() {
|
SConfig *cfgInit() {
|
||||||
SConfig *pCfg = calloc(1, sizeof(SConfig));
|
SConfig *pCfg = calloc(1, sizeof(SConfig));
|
||||||
if (pCfg == NULL) {
|
if (pCfg == NULL) {
|
||||||
|
@ -505,56 +508,37 @@ const char *cfgDtypeStr(ECfgDataType type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfgPrintCfg(SConfig *pCfg) {
|
|
||||||
uInfo("taos global config");
|
|
||||||
uInfo("==================================");
|
|
||||||
|
|
||||||
SConfigItem *pItem = cfgIterate(pCfg, NULL);
|
|
||||||
while (pItem != NULL) {
|
|
||||||
switch (pItem->dtype) {
|
|
||||||
case CFG_DTYPE_BOOL:
|
|
||||||
uInfo("cfg:%s, value:%u src:%s", pItem->name, pItem->bval, cfgStypeStr(pItem->stype));
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_INT32:
|
|
||||||
uInfo("cfg:%s, value:%d src:%s", pItem->name, pItem->i32, cfgStypeStr(pItem->stype));
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_INT64:
|
|
||||||
uInfo("cfg:%s, value:%" PRId64 " src:%s", pItem->name, pItem->i64, cfgStypeStr(pItem->stype));
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_FLOAT:
|
|
||||||
uInfo("cfg:%s, value:%f src:%s", pItem->name, pItem->fval, cfgStypeStr(pItem->stype));
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_STRING:
|
|
||||||
case CFG_DTYPE_IPSTR:
|
|
||||||
case CFG_DTYPE_DIR:
|
|
||||||
case CFG_DTYPE_LOCALE:
|
|
||||||
case CFG_DTYPE_CHARSET:
|
|
||||||
case CFG_DTYPE_TIMEZONE:
|
|
||||||
uInfo("cfg:%s, value:%s src:%s", pItem->name, pItem->str, cfgStypeStr(pItem->stype));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pItem = cfgIterate(pCfg, pItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cfgDumpCfg(SConfig *pCfg) {
|
void cfgDumpCfg(SConfig *pCfg) {
|
||||||
uInfo("global config");
|
uInfo(" global config");
|
||||||
uInfo("==================================");
|
uInfo("=================================================================");
|
||||||
|
|
||||||
|
char src[CFG_SRC_PRINT_LEN + 1] = {0};
|
||||||
|
char name[CFG_NAME_PRINT_LEN + 1] = {0};
|
||||||
|
|
||||||
SConfigItem *pItem = cfgIterate(pCfg, NULL);
|
SConfigItem *pItem = cfgIterate(pCfg, NULL);
|
||||||
while (pItem != NULL) {
|
while (pItem != NULL) {
|
||||||
|
tstrncpy(src, cfgStypeStr(pItem->stype), CFG_SRC_PRINT_LEN);
|
||||||
|
for (int32_t i = 0; i < CFG_SRC_PRINT_LEN; ++i) {
|
||||||
|
if (src[i] == 0) src[i] = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
tstrncpy(name, pItem->name, CFG_NAME_PRINT_LEN);
|
||||||
|
for (int32_t i = 0; i < CFG_NAME_PRINT_LEN; ++i) {
|
||||||
|
if (name[i] == 0) name[i] = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
case CFG_DTYPE_BOOL:
|
case CFG_DTYPE_BOOL:
|
||||||
uInfo("cfg:%s, value:%u src:%s", pItem->name, pItem->bval, cfgStypeStr(pItem->stype));
|
uInfo("%s %s %u", src, name, pItem->bval);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT32:
|
case CFG_DTYPE_INT32:
|
||||||
uInfo("cfg:%s, value:%d src:%s", pItem->name, pItem->i32, cfgStypeStr(pItem->stype));
|
uInfo("%s %s %d", src, name, pItem->i32);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_INT64:
|
case CFG_DTYPE_INT64:
|
||||||
uInfo("cfg:%s, value:%" PRId64 " src:%s", pItem->name, pItem->i64, cfgStypeStr(pItem->stype));
|
uInfo("%s %s %" PRId64, src, name, pItem->i64);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_FLOAT:
|
case CFG_DTYPE_FLOAT:
|
||||||
uInfo("cfg:%s, value:%f src:%s", pItem->name, pItem->fval, cfgStypeStr(pItem->stype));
|
uInfo("%s %s %f", src, name, pItem->fval);
|
||||||
break;
|
break;
|
||||||
case CFG_DTYPE_STRING:
|
case CFG_DTYPE_STRING:
|
||||||
case CFG_DTYPE_IPSTR:
|
case CFG_DTYPE_IPSTR:
|
||||||
|
@ -562,13 +546,13 @@ void cfgDumpCfg(SConfig *pCfg) {
|
||||||
case CFG_DTYPE_LOCALE:
|
case CFG_DTYPE_LOCALE:
|
||||||
case CFG_DTYPE_CHARSET:
|
case CFG_DTYPE_CHARSET:
|
||||||
case CFG_DTYPE_TIMEZONE:
|
case CFG_DTYPE_TIMEZONE:
|
||||||
uInfo("cfg:%s, value:%s src:%s", pItem->name, pItem->str, cfgStypeStr(pItem->stype));
|
uInfo("%s %s %s", src, name, pItem->str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pItem = cfgIterate(pCfg, pItem);
|
pItem = cfgIterate(pCfg, pItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
uInfo("==================================");
|
uInfo("=================================================================");
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
// int32_t cfgCheck(SConfig *pCfg) {
|
// int32_t cfgCheck(SConfig *pCfg) {
|
||||||
|
|
|
@ -23,7 +23,6 @@ char tsOsName[10] = "Windows";
|
||||||
char configDir[PATH_MAX] = "C:/TDengine/cfg";
|
char configDir[PATH_MAX] = "C:/TDengine/cfg";
|
||||||
char tsDataDir[PATH_MAX] = "C:/TDengine/data";
|
char tsDataDir[PATH_MAX] = "C:/TDengine/data";
|
||||||
char tsLogDir[PATH_MAX] = "C:/TDengine/log";
|
char tsLogDir[PATH_MAX] = "C:/TDengine/log";
|
||||||
char tsScriptDir[PATH_MAX] = "C:/TDengine/script";
|
|
||||||
char tsTempDir[PATH_MAX] = "C:\\Windows\\Temp";
|
char tsTempDir[PATH_MAX] = "C:\\Windows\\Temp";
|
||||||
|
|
||||||
extern taosWinSocketInit();
|
extern taosWinSocketInit();
|
||||||
|
@ -47,7 +46,6 @@ char tsOsName[10] = "Darwin";
|
||||||
char configDir[PATH_MAX] = "/usr/local/etc/taos";
|
char configDir[PATH_MAX] = "/usr/local/etc/taos";
|
||||||
char tsDataDir[PATH_MAX] = "/usr/local/var/lib/taos";
|
char tsDataDir[PATH_MAX] = "/usr/local/var/lib/taos";
|
||||||
char tsLogDir[PATH_MAX] = "/usr/local/var/log/taos";
|
char tsLogDir[PATH_MAX] = "/usr/local/var/log/taos";
|
||||||
char tsScriptDir[PATH_MAX] = "/usr/local/etc/taos";
|
|
||||||
char tsTempDir[PATH_MAX] = "/tmp/taosd";
|
char tsTempDir[PATH_MAX] = "/tmp/taosd";
|
||||||
|
|
||||||
void osInit() {}
|
void osInit() {}
|
||||||
|
@ -58,7 +56,6 @@ char tsOsName[10] = "Linux";
|
||||||
char configDir[PATH_MAX] = "/etc/taos";
|
char configDir[PATH_MAX] = "/etc/taos";
|
||||||
char tsDataDir[PATH_MAX] = "/var/lib/taos";
|
char tsDataDir[PATH_MAX] = "/var/lib/taos";
|
||||||
char tsLogDir[PATH_MAX] = "/var/log/taos";
|
char tsLogDir[PATH_MAX] = "/var/log/taos";
|
||||||
char tsScriptDir[PATH_MAX] = "/etc/taos";
|
|
||||||
char tsTempDir[PATH_MAX] = "/tmp/";
|
char tsTempDir[PATH_MAX] = "/tmp/";
|
||||||
|
|
||||||
void osInit() {}
|
void osInit() {}
|
||||||
|
|
Loading…
Reference in New Issue