提交 612dd719 编写于 作者: S Shengliang Guan

os env

上级 1383e53d
......@@ -22,33 +22,31 @@
extern "C" {
#endif
typedef struct SOsEnv SOsEnv;
extern char tsOsName[];
extern char tsTimezone[];
extern char tsCharset[];
extern char tsLocale[];
extern int8_t tsDaylight;
extern bool tsEnableCoreFile;
extern int64_t tsPageSize;
extern int64_t tsOpenMax;
extern int64_t tsStreamMax;
extern int32_t tsNumOfCores;
extern int32_t tsTotalMemoryMB;
extern char configDir[];
extern char tsDataDir[];
extern char tsLogDir[];
extern char tsTempDir[];
extern SDiskSpace tsDataSpace;
extern SDiskSpace tsLogSpace;
extern SDiskSpace tsTempSpace;
void osInit();
void osUpdate();
bool osLogSpaceAvailable();
int8_t osDaylight();
const char *osLogDir();
const char *osTempDir();
const char *osDataDir();
const char *osName();
const char *osTimezone();
const char *osLocale();
const char *osCharset();
void osSetLogDir(const char *logDir);
void osSetTempDir(const char *tempDir);
void osSetDataDir(const char *dataDir);
void osSetLogReservedSpace(float sizeInGB);
void osSetTempReservedSpace(float sizeInGB);
void osSetDataReservedSpace(float sizeInGB);
bool osLogSpaceAvailable();
void osSetTimezone(const char *timezone);
void osSetLocale(const char *locale, const char *charset);
bool osSetEnableCore(bool enable);
#ifdef __cplusplus
}
......
......@@ -37,14 +37,6 @@ typedef struct SDiskSpace {
SDiskSize size;
} SDiskSpace;
extern int64_t tsPageSize;
extern int64_t tsOpenMax;
extern int64_t tsStreamMax;
extern int32_t tsNumOfCores;
extern int32_t tsTotalMemoryMB;
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize);
int32_t taosGetCpuCores();
void taosGetSystemInfo();
......
......@@ -207,7 +207,7 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
}
static void taosAddClientLogCfg(SConfig *pCfg) {
cfgAddDir(pCfg, "logDir", osLogDir(), 1);
cfgAddDir(pCfg, "logDir", tsLogDir, 1);
cfgAddFloat(pCfg, "minimalLogDirGB", 1.0f, 0.001f, 10000000, 1);
cfgAddInt32(pCfg, "numOfLogLines", tsNumOfLogLines, 1000, 2000000000, 1);
cfgAddBool(pCfg, "asyncLog", tsAsyncLog, 1);
......@@ -248,7 +248,7 @@ static void taosAddClientCfg(SConfig *pCfg) {
cfgAddString(pCfg, "secondEp", defaultSecondEp, 1);
cfgAddString(pCfg, "fqdn", defaultFqdn, 1);
cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056, 1);
cfgAddDir(pCfg, "tempDir", osTempDir(), 1);
cfgAddDir(pCfg, "tempDir", tsTempDir, 1);
cfgAddFloat(pCfg, "minimalTempDirGB", 1.0f, 0.001f, 10000000, 1);
cfgAddFloat(pCfg, "numOfThreadsPerCore", tsNumOfThreadsPerCore, 0, 10, 1);
cfgAddInt32(pCfg, "maxTmrCtrl", tsMaxTmrCtrl, 8, 2048, 1);
......@@ -263,11 +263,12 @@ static void taosAddClientCfg(SConfig *pCfg) {
cfgAddInt32(pCfg, "maxNumOfOrderedRes", tsMaxNumOfOrderedResults, 128, TSDB_MAX_ALLOWED_SQL_LEN, 1);
cfgAddBool(pCfg, "keepColumnName", tsKeepOriginalColumnName, 1);
cfgAddInt32(pCfg, "maxBinaryDisplayWidth", tsMaxBinaryDisplayWidth, 1, 65536, 1);
cfgAddTimezone(pCfg, "timezone", osTimezone());
cfgAddLocale(pCfg, "locale", osLocale());
cfgAddCharset(pCfg, "charset", osCharset());
cfgAddTimezone(pCfg, "timezone", tsTimezone);
cfgAddLocale(pCfg, "locale", tsLocale);
cfgAddCharset(pCfg, "charset", tsCharset);
cfgAddBool(pCfg, "enableCoreFile", 0, 1);
cfgAddInt32(pCfg, "numOfCores", tsNumOfCores, 1, 100000, 1);
cfgAddString(pCfg, "version", version, 1);
cfgAddString(pCfg, "compatible_version", compatible_version, 1);
cfgAddString(pCfg, "gitinfo", gitinfo, 1);
......@@ -277,7 +278,7 @@ static void taosAddClientCfg(SConfig *pCfg) {
static void taosAddServerCfg(SConfig *pCfg) {
cfgAddInt32(pCfg, "supportVnodes", 256, 0, 65536, 0);
cfgAddDir(pCfg, "dataDir", osDataDir(), 0);
cfgAddDir(pCfg, "dataDir", tsDataDir, 0);
cfgAddFloat(pCfg, "minimalDataDirGB", 2.0f, 0.001f, 10000000, 0);
cfgAddInt32(pCfg, "numOfCommitThreads", tsNumOfCommitThreads, 1, 100, 0);
cfgAddFloat(pCfg, "ratioOfQueryCores", tsRatioOfQueryCores, 0, 2, 0);
......@@ -301,8 +302,8 @@ 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);
tstrncpy(tsLogDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX);
tsLogSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval;
tsNumOfLogLines = cfgGetItem(pCfg, "numOfLogLines")->i32;
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
tsLogKeepDays = cfgGetItem(pCfg, "logKeepDays")->i32;
......@@ -331,8 +332,8 @@ static void taosSetClientCfg(SConfig *pCfg) {
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_EP_LEN);
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
snprintf(tsLocalEp, sizeof(tsLocalEp), "%s:%u", tsLocalFqdn, tsServerPort);
osSetTempDir(cfgGetItem(pCfg, "tempDir")->str);
osSetDataReservedSpace(cfgGetItem(pCfg, "minimalTempDirGB")->fval);
tstrncpy(tsLogDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX);
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalTempDirGB")->fval;
tsNumOfThreadsPerCore = cfgGetItem(pCfg, "maxTmrCtrl")->fval;
tsMaxTmrCtrl = cfgGetItem(pCfg, "maxTmrCtrl")->i32;
......@@ -350,28 +351,27 @@ static void taosSetClientCfg(SConfig *pCfg) {
SConfigItem *pItem = cfgGetItem(pCfg, "timezone");
osSetTimezone(pItem->str);
uDebug("timezone format changed from %s to %s", pItem->str, osTimezone());
cfgSetItem(pCfg, "timezone", osTimezone(), pItem->stype);
uDebug("timezone format changed from %s to %s", pItem->str, tsTimezone);
cfgSetItem(pCfg, "timezone", tsTimezone, pItem->stype);
const char *locale = cfgGetItem(pCfg, "locale")->str;
const char *charset = cfgGetItem(pCfg, "charset")->str;
osSetLocale(locale, charset);
taosSetSystemLocale(locale, charset);
if (tsNumOfCores <= 1) {
tsNumOfCores = 2;
}
bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval;
taosSetCoreDump(enableCore);
taosSetConsoleEcho(enableCore);
// todo
tsVersion = 30000000;
}
static void taosSetServerCfg(SConfig *pCfg) {
osSetDataDir(cfgGetItem(pCfg, "dataDir")->str);
osSetTempReservedSpace(cfgGetItem(pCfg, "minimalDataDirGB")->fval);
tstrncpy(tsDataDir, cfgGetItem(pCfg, "dataDir")->str, PATH_MAX);
tsTempSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval;
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
tsRatioOfQueryCores = cfgGetItem(pCfg, "ratioOfQueryCores")->fval;
tsMaxNumOfDistinctResults = cfgGetItem(pCfg, "maxNumOfDistinctRes")->i32;
......
......@@ -23,7 +23,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
pTSBuf->autoDelete = autoDelete;
taosGetTmpfilePath(osTempDir(), "join", pTSBuf->path);
taosGetTmpfilePath(tsTempDir, "join", pTSBuf->path);
pTSBuf->f = fopen(pTSBuf->path, "wb+");
if (pTSBuf->f == NULL) {
free(pTSBuf);
......
......@@ -371,9 +371,9 @@ void dndSendStatusReq(SDnode *pDnode) {
req.clusterCfg.checkTime = 0;
char timestr[32] = "1970-01-01 00:00:00.00";
(void)taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
memcpy(req.clusterCfg.timezone, osTimezone(), TD_TIMEZONE_LEN);
memcpy(req.clusterCfg.locale, osLocale(), TD_LOCALE_LEN);
memcpy(req.clusterCfg.charset, osCharset(), TD_LOCALE_LEN);
memcpy(req.clusterCfg.timezone, tsTimezone, TD_TIMEZONE_LEN);
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);
memcpy(req.clusterCfg.charset, tsCharset, TD_LOCALE_LEN);
taosRUnLockLatch(&pMgmt->latch);
req.pVloads = taosArrayInit(TSDB_MAX_VNODES, sizeof(SVnodeLoad));
......
......@@ -33,7 +33,7 @@ void Testbase::InitLog(const char* path) {
taosRemoveDir(path);
taosMkDir(path);
osSetLogDir(path);
tstrncpy(tsLogDir, path, PATH_MAX);
if (taosInitLog("taosdlog", 1) != 0) {
printf("failed to init log file\n");
}
......
......@@ -277,19 +277,19 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
return DND_REASON_STATUS_INTERVAL_NOT_MATCH;
}
if ((0 != strcasecmp(pCfg->timezone, osTimezone())) && (pMnode->checkTime != pCfg->checkTime)) {
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, osTimezone(),
if ((0 != strcasecmp(pCfg->timezone, tsTimezone)) && (pMnode->checkTime != pCfg->checkTime)) {
mError("timezone [%s - %s] [%" PRId64 " - %" PRId64 "] cfg inconsistent", pCfg->timezone, tsTimezone,
pCfg->checkTime, pMnode->checkTime);
return DND_REASON_TIME_ZONE_NOT_MATCH;
}
if (0 != strcasecmp(pCfg->locale, osLocale())) {
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, osLocale());
if (0 != strcasecmp(pCfg->locale, tsLocale)) {
mError("locale [%s - %s] cfg inconsistent", pCfg->locale, tsLocale);
return DND_REASON_LOCALE_NOT_MATCH;
}
if (0 != strcasecmp(pCfg->charset, osCharset())) {
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, osCharset());
if (0 != strcasecmp(pCfg->charset, tsCharset)) {
mError("charset [%s - %s] cfg inconsistent.", pCfg->charset, tsCharset);
return DND_REASON_CHARSET_NOT_MATCH;
}
......@@ -669,15 +669,15 @@ static int32_t mndRetrieveConfigs(SMnodeMsg *pReq, SShowObj *pShow, char *data,
numOfRows++;
cfgOpts[numOfRows] = "timezone";
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osTimezone());
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", tsTimezone);
numOfRows++;
cfgOpts[numOfRows] = "locale";
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osLocale());
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", tsLocale);
numOfRows++;
cfgOpts[numOfRows] = "charset";
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", osCharset());
snprintf(cfgVals[numOfRows], TSDB_CONIIG_VALUE_LEN, "%s", tsCharset);
numOfRows++;
for (int32_t i = 0; i < numOfRows; i++) {
......
......@@ -132,7 +132,7 @@ void ctgTestInitLogFile() {
ctgDbgEnableDebug("api");
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", osLogDir());
printf("failed to open log file in directory:%s\n", tsLogDir);
}
}
......
......@@ -4628,7 +4628,7 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr
getIntermediateBufInfo(pRuntimeEnv, &ps, &pQueryAttr->intermediateResultRowSize);
int32_t TENMB = 1024*1024*10;
int32_t code = createDiskbasedBuffer(&pRuntimeEnv->pResultBuf, ps, TENMB, pQInfo->qId, osTempDir());
int32_t code = createDiskbasedBuffer(&pRuntimeEnv->pResultBuf, ps, TENMB, pQInfo->qId, tsTempDir);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
......
......@@ -254,7 +254,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
resetSlotInfo(pBucket);
int32_t ret = createDiskbasedBuffer(&pBucket->pBuffer, pBucket->bufPageSize, pBucket->bufPageSize * 512, 1, osTempDir());
int32_t ret = createDiskbasedBuffer(&pBucket->pBuffer, pBucket->bufPageSize, pBucket->bufPageSize * 512, 1, tsTempDir);
if (ret != 0) {
tMemBucketDestroy(pBucket);
return NULL;
......
......@@ -55,7 +55,7 @@ int32_t initUdfInfo(SUdfInfo* pUdfInfo) {
} else {
char path[PATH_MAX] = {0};
taosGetTmpfilePath("script", path, osTempDir());
taosGetTmpfilePath("script", path, tsTempDir);
FILE* file = fopen(path, "w+");
......
......@@ -30,7 +30,7 @@ static void EnvInit() {
taosRemoveDir(path.c_str());
taosMkDir(path.c_str());
// init log file
osSetLogDir( path.c_str());
tstrncpy(tsLogDir, path.c_str(), PATH_MAX);
if (taosInitLog("tindex.idx", 1) != 0) {
printf("failed to init log");
}
......
......@@ -204,7 +204,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
bool isSigned = false;
toInteger(pToken->z, pToken->n, 10, &ts, &isSigned);
} else { // parse the RFC-3339/ISO-8601 timestamp format string
if (taosParseTime(pToken->z, time, pToken->n, timePrec, osDaylight()) != TSDB_CODE_SUCCESS) {
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
}
......
......@@ -578,7 +578,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
return DEAL_RES_ERROR;
}
int32_t len = trimStringCopy(pVal->literal, n, tmp);
if (taosParseTime(tmp, &pVal->datum.i, len, pVal->node.resType.precision, osDaylight()) != TSDB_CODE_SUCCESS) {
if (taosParseTime(tmp, &pVal->datum.i, len, pVal->node.resType.precision, tsDaylight) != TSDB_CODE_SUCCESS) {
tfree(tmp);
generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
return DEAL_RES_ERROR;
......
......@@ -1639,7 +1639,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
bool isSigned = false;
toInteger(pToken->z, pToken->n, 10, &ts, &isSigned);
} else { // parse the RFC-3339/ISO-8601 timestamp format string
if (taosParseTime(pToken->z, time, pToken->n, timePrec, osDaylight()) != TSDB_CODE_SUCCESS) {
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
}
......
......@@ -102,7 +102,7 @@ void qwtInitLogFile() {
qDebugFlag = 159;
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", osLogDir());
printf("failed to open log file in directory:%s\n", tsLogDir);
}
}
......
......@@ -53,7 +53,7 @@ void flttInitLogFile() {
qDebugFlag = 159;
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", osLogDir());
printf("failed to open log file in directory:%s\n", tsLogDir);
}
}
......
......@@ -52,7 +52,7 @@ void scltInitLogFile() {
qDebugFlag = 159;
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", osLogDir());
printf("failed to open log file in directory:%s\n", tsLogDir);
}
}
......
......@@ -67,7 +67,7 @@ void schtInitLogFile() {
qDebugFlag = 159;
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", osLogDir());
printf("failed to open log file in directory:%s\n", tsLogDir);
}
}
......
......@@ -155,7 +155,7 @@ class TransObj {
taosRemoveDir(path.c_str());
taosMkDir(path.c_str());
osSetLogDir(path.c_str());
tstrncpy(tsLogDir, path.c_str(), PATH_MAX);
if (taosInitLog("taosdlog", 1) != 0) {
printf("failed to init log file\n");
}
......
......@@ -17,68 +17,31 @@
#include "osEnv.h"
extern void taosWinSocketInit();
char configDir[PATH_MAX] = {0};
typedef struct SOsEnv {
char dataDir[PATH_MAX];
char logDir[PATH_MAX];
char tempDir[PATH_MAX];
SDiskSpace dataSpace;
SDiskSpace logSpace;
SDiskSpace tempSpace;
char osName[16];
char timezone[TD_TIMEZONE_LEN];
char locale[TD_LOCALE_LEN];
char charset[TD_CHARSET_LEN];
int8_t daylight;
bool enableCoreFile;
} SOsEnv;
static SOsEnv env = {0};
SOsEnv *osEnv() { return &env; }
void osInitImp() {
taosGetSystemLocale(env.locale, env.charset);
taosGetSystemTimezone(env.timezone);
osSetTimezone(env.timezone);
}
void osUpdate() {
if (env.logDir[0] != 0) {
taosGetDiskSize(env.logDir, &env.logSpace.size);
}
if (env.dataDir[0] != 0) {
taosGetDiskSize(env.dataDir, &env.dataSpace.size);
}
if (env.tempDir[0] != 0) {
taosGetDiskSize(env.tempDir, &env.tempSpace.size);
}
}
bool osLogSpaceAvailable() { return env.logSpace.reserved <= env.logSpace.size.avail; }
int8_t osDaylight() { return env.daylight; }
const char *osLogDir() { return env.logDir; }
const char *osTempDir() { return env.tempDir; }
const char *osDataDir() { return env.dataDir; }
const char *osName() { return env.osName; }
const char *osTimezone() { return env.timezone; }
const char *osLocale() { return env.locale; }
const char *osCharset() { return env.charset; }
void osSetLogDir(const char *logDir) { tstrncpy(env.logDir, logDir, PATH_MAX); }
void osSetTempDir(const char *tempDir) { tstrncpy(env.tempDir, tempDir, PATH_MAX); }
void osSetDataDir(const char *dataDir) { tstrncpy(env.dataDir, dataDir, PATH_MAX); }
void osSetLogReservedSpace(float sizeInGB) { env.logSpace.reserved = sizeInGB; }
void osSetTempReservedSpace(float sizeInGB) { env.tempSpace.reserved = sizeInGB; }
void osSetDataReservedSpace(float sizeInGB) { env.dataSpace.reserved = sizeInGB; }
void osSetTimezone(const char *timezone) { taosSetSystemTimezone(timezone, env.timezone, &env.daylight); }
void osSetLocale(const char *locale, const char *charset) { taosSetSystemLocale(locale, charset); }
bool osSetEnableCore(bool enable) { env.enableCoreFile = enable; }
char configDir[PATH_MAX] = {0};
char tsDataDir[PATH_MAX];
char tsLogDir[PATH_MAX];
char tsTempDir[PATH_MAX];
SDiskSpace tsDataSpace;
SDiskSpace tsLogSpace;
SDiskSpace tsTempSpace;
char tsOsName[16];
char tsTimezone[TD_TIMEZONE_LEN];
char tsLocale[TD_LOCALE_LEN];
char tsCharset[TD_CHARSET_LEN];
int8_t tsDaylight;
bool tsEnableCoreFile;
int64_t tsPageSize;
int64_t tsOpenMax;
int64_t tsStreamMax;
int32_t tsNumOfCores;
int32_t tsTotalMemoryMB;
void osInit() {
srand(taosSafeRand());
taosGetSystemLocale(tsLocale, tsCharset);
taosGetSystemTimezone(tsTimezone);
taosSetSystemTimezone(tsTimezone, tsTimezone, &tsDaylight);
taosGetSystemInfo();
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
......@@ -89,34 +52,50 @@ void osInit() {
tmpDir = getenv("temp");
}
if (tmpDir != NULL) {
strcpy(env.tempDir, tmpDir);
strcpy(tsTempDir, tmpDir);
}
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");
strcpy(tsDataDir, "C:\\TDengine\\data");
strcpy(tsLogDir, "C:\\TDengine\\log");
strcpy(tsTempDir, "C:\\Windows\\Temp");
strcpy(tsOsName, "Windows");
#elif defined(_TD_DARWIN_64)
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");
strcpy(tsDataDir, "/usr/local/var/lib/taos");
strcpy(tsLogDir, "/usr/local/var/log/taos");
strcpy(tsTempDir, "/usr/local/etc/taos");
strcpy(tsOsName, "Darwin");
#else
if (configDir[0] == 0) {
strcpy(configDir, "/etc/taos");
}
strcpy(env.dataDir, "/var/lib/taos");
strcpy(env.logDir, "/var/log/taos");
strcpy(env.tempDir, "/tmp");
strcpy(env.osName, "Linux");
strcpy(tsDataDir, "/var/lib/taos");
strcpy(tsLogDir, "/var/log/taos");
strcpy(tsTempDir, "/tmp");
strcpy(tsOsName, "Linux");
#endif
}
\ No newline at end of file
}
void osUpdate() {
if (tsLogDir[0] != 0) {
taosGetDiskSize(tsLogDir, &tsLogSpace.size);
}
if (tsDataDir[0] != 0) {
taosGetDiskSize(tsDataDir, &tsDataSpace.size);
}
if (tsTempDir[0] != 0) {
taosGetDiskSize(tsTempDir, &tsTempSpace.size);
}
}
bool osLogSpaceAvailable() { return tsLogSpace.reserved <= tsLogSpace.size.avail; }
void osSetTimezone(const char *timezone) { taosSetSystemTimezone(tsTimezone, tsTimezone, &tsDaylight); }
......@@ -111,7 +111,7 @@ int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
diskSize->used = (int64_t)(i64TotalBytes - i64FreeBytes);
return 0;
} else {
//printf("failed to get disk size, dataDir:%s errno:%s", osDataDir(), strerror(errno));
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
......@@ -316,7 +316,7 @@ void taosSetCoreDump() {}
int32_t taosGetDiskSize(char *dataDir, SDiskSize *diskSize) {
struct statvfs info;
if (statvfs(dataDir, &info)) {
//printf("failed to get disk size, dataDir:%s errno:%s", osDataDir(), strerror(errno));
//printf("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
} else {
......
......@@ -121,7 +121,7 @@ int32_t taosInitLog(const char *logName, int maxFiles) {
osUpdate();
char fullName[PATH_MAX] = {0};
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", osLogDir(), logName);
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName);
tsLogObj.logHandle = taosLogBuffNew(TSDB_DEFAULT_LOG_BUF_SIZE);
if (tsLogObj.logHandle == NULL) return -1;
......@@ -187,7 +187,7 @@ static void taosKeepOldLog(char *oldName) {
}
}
taosRemoveOldFiles(osLogDir(), TABS(tsLogKeepDays));
taosRemoveOldFiles(tsLogDir, TABS(tsLogKeepDays));
}
static void *taosThreadToOpenNewFile(void *param) {
......
......@@ -68,11 +68,11 @@ TAOS *shellInit(SShellArguments *_args) {
printf("\n");
if (!_args->is_use_passwd) {
#ifdef TD_WINDOWS
strcpy(osName(), "Windows");
strcpy(tsOsName, "Windows");
#elif defined(TD_DARWIN)
strcpy(osName(), "Darwin");
strcpy(tsOsName, "Darwin");
#endif
printf(CLIENT_VERSION, osName(), taos_get_client_info());
printf(CLIENT_VERSION, tsOsName, taos_get_client_info());
}
fflush(stdout);
......
......@@ -184,7 +184,7 @@ static void parse_args(
for (int i = 1; i < argc; i++) {
if ((strncmp(argv[i], "-p", 2) == 0)
|| (strncmp(argv[i], "--password", 10) == 0)) {
printf(LINUXCLIENT_VERSION, osName(), taos_get_client_info());
printf(LINUXCLIENT_VERSION, tsOsName, taos_get_client_info());
if ((strlen(argv[i]) == 2)
|| (strncmp(argv[i], "--password", 10) == 0)) {
printf("Enter password: ");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册