提交 942d0b69 编写于 作者: S Shengliang Guan

osenv

上级 f0b75b96
......@@ -22,7 +22,7 @@
extern "C" {
#endif
typedef struct SEnvVar {
typedef struct SOsEnv {
char dataDir[PATH_MAX];
char logDir[PATH_MAX];
char tempDir[PATH_MAX];
......@@ -34,20 +34,20 @@ typedef struct SEnvVar {
char locale[TD_LOCALE_LEN];
char charset[TD_CHARSET_LEN];
int8_t daylight;
} SEnvVar;
} SOsEnv;
extern char configDir[];
void osInit();
SEnvVar *osEnv();
void osUpdate();
bool osLogSpaceAvailable();
char *osLogDir();
char *osTempDir();
char *osDataDir();
char *osName();
char *osTimezone();
int8_t osDaylight();
void osInit();
SOsEnv *osEnv();
void osUpdate();
bool osLogSpaceAvailable();
char *osLogDir();
char *osTempDir();
char *osDataDir();
char *osName();
char *osTimezone();
int8_t osDaylight();
void osSetTimezone(const char*timezone);
......
......@@ -47,7 +47,7 @@ static int32_t dmnAddDirCfg(SConfig *pCfg) {
}
static int32_t dmnCheckDirCfg(SConfig *pCfg) {
SEnvVar *pEnv = osEnv();
SOsEnv *pEnv = osEnv();
tstrncpy(pEnv->dataDir, cfgGetItem(pCfg, "dataDir")->str, PATH_MAX);
tstrncpy(pEnv->tempDir, cfgGetItem(pCfg, "tempDir")->str, PATH_MAX);
pEnv->dataSpace.reserved = cfgGetItem(pCfg, "minimalDataDirGB")->fval;
......
......@@ -17,7 +17,7 @@
#include "dmnInt.h"
int32_t dmnAddLogCfg(SConfig *pCfg) {
if (cfgAddDir(pCfg, "logDir", "/var/log/taos") != 0) return -1;
if (cfgAddDir(pCfg, "logDir", osLogDir()) != 0) return -1;
if (cfgAddFloat(pCfg, "minimalLogDirGB", 1.0f, 0.001f, 10000000) != 0) return -1;
if (cfgAddBool(pCfg, "asyncLog", 1) != 0) return -1;
if (cfgAddInt32(pCfg, "numOfLogLines", 10000000, 1000, 2000000000) != 0) return -1;
......@@ -41,8 +41,7 @@ int32_t dmnAddLogCfg(SConfig *pCfg) {
}
int32_t dmnSetLogCfg(SConfig *pCfg) {
SEnvVar *pEnv = osEnv();
SOsEnv *pEnv = osEnv();
tstrncpy(pEnv->logDir, cfgGetItem(pCfg, "logDir")->str, PATH_MAX);
pEnv->logSpace.reserved = cfgGetItem(pCfg, "minimalLogDirGB")->fval;
tsAsyncLog = cfgGetItem(pCfg, "asyncLog")->bval;
......
......@@ -97,6 +97,8 @@ int32_t dmnRunDnode(SConfig *pCfg) {
}
int main(int argc, char const *argv[]) {
osInit();
if (dmnParseOption(argc, argv) != 0) {
return -1;
}
......
......@@ -16,10 +16,10 @@
#define _DEFAULT_SOURCE
#include "osEnv.h"
SEnvVar env = {0};
char configDir[PATH_MAX] = {0};
SOsEnv env = {0};
char configDir[PATH_MAX] = {0};
SEnvVar *osEnv() { return &env; }
SOsEnv *osEnv() { return &env; }
void osInitImp() {
osGetSystemTimezone(env.timezone);
......
......@@ -118,6 +118,7 @@ static int32_t taosStartLog() {
int32_t taosInitLog(const char *logName, int maxFiles) {
if (tsLogInited) return 0;
osUpdate();
char fullName[PATH_MAX] = {0};
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", osLogDir(), logName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册