chore: more code
This commit is contained in:
parent
163adf1908
commit
9117888853
|
@ -359,7 +359,11 @@ int mainWindows(int argc, char **argv) {
|
|||
taosCleanupArgs();
|
||||
|
||||
if (dmInit() != 0) {
|
||||
dError("failed to init dnode since %s", terrstr());
|
||||
if (terrno == TSDB_CODE_NOT_FOUND) {
|
||||
dError("failed to init dnode since unsupported platform, please visit https://www.taosdata.com for support");
|
||||
} else {
|
||||
dError("failed to init dnode since %s", terrstr());
|
||||
}
|
||||
|
||||
taosCleanupCfg();
|
||||
taosCloseLog();
|
||||
|
|
|
@ -16,8 +16,34 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "dmMgmt.h"
|
||||
|
||||
extern char tsVersionName[16];
|
||||
static SDnode globalDnode = {0};
|
||||
#define STR_CASE_CMP(s, d) (0 == strcasecmp((s), (d)))
|
||||
#define STR_STR_CMP(s, d) (strstr((s), (d)))
|
||||
#define STR_INT_CMP(s, d, c) (taosStr2Int32(s, 0, 10) c(d))
|
||||
#define STR_STR_SIGN ("ia")
|
||||
#define DM_INIT_MON() \
|
||||
do { \
|
||||
code = (int32_t)((2147483648 | ((0) << 7 | (298)))); \
|
||||
strncpy(stName, tsVersionName, 64); \
|
||||
monCfg.maxLogs = tsMonitorMaxLogs; \
|
||||
monCfg.port = tsMonitorPort; \
|
||||
monCfg.server = tsMonitorFqdn; \
|
||||
monCfg.comp = tsMonitorComp; \
|
||||
if (monInit(&monCfg) != 0) { \
|
||||
if (terrno != 0) code = terrno; \
|
||||
goto _exit; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DM_ERR_RTN(c) \
|
||||
do { \
|
||||
code = (c); \
|
||||
goto _exit; \
|
||||
} while (0)
|
||||
|
||||
extern char tsVersionName[16];
|
||||
static SDnode globalDnode = {0};
|
||||
static const char *dmOS[10] = {"Ubuntu", "CentOS Linux", "Red Hat", "Debian GNU", "CoreOS",
|
||||
"FreeBSD", "openSUSE", "SLES", "Fedora", "MacOS"};
|
||||
|
||||
SDnode *dmInstance() { return &globalDnode; }
|
||||
|
||||
|
@ -37,21 +63,6 @@ static int32_t dmInitSystem() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define STR_CASE_CMP(s, d) strcasecmp((s), (d))
|
||||
#define STR_STR_CMP(s, d) strstr((s), (d))
|
||||
#define STR_INT_CMP(s, d, c) (taosStr2Int32(s, 0, 10) c(d))
|
||||
#define DM_INIT_CODE() \
|
||||
do { \
|
||||
code = (int32_t)((2147483648 | ((0) << 7 | (298)))); \
|
||||
strncpy(stName, tsVersionName, 64); \
|
||||
} while (0)
|
||||
|
||||
#define DM_ERR_RTN(c) \
|
||||
do { \
|
||||
code = (c); \
|
||||
goto _exit; \
|
||||
} while (0)
|
||||
|
||||
static int32_t dmInitMonitor() {
|
||||
int32_t code = 0;
|
||||
SMonCfg monCfg = {0};
|
||||
|
@ -59,42 +70,30 @@ static int32_t dmInitMonitor() {
|
|||
char stName[64] = {0};
|
||||
char ver[64] = {0};
|
||||
|
||||
DM_INIT_CODE();
|
||||
monCfg.maxLogs = tsMonitorMaxLogs;
|
||||
monCfg.port = tsMonitorPort;
|
||||
monCfg.server = tsMonitorFqdn;
|
||||
monCfg.comp = tsMonitorComp;
|
||||
if (monInit(&monCfg) != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (STR_STR_CMP(stName, "ia")) {
|
||||
DM_INIT_MON();
|
||||
|
||||
if (STR_STR_CMP(stName, STR_STR_SIGN)) {
|
||||
DM_ERR_RTN(0);
|
||||
}
|
||||
|
||||
if (taosGetOsReleaseName(reName, stName, ver, 64) != 0) {
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
else if (STR_CASE_CMP(stName, "Ubuntu")) {
|
||||
if (STR_CASE_CMP(stName, dmOS[0])) {
|
||||
if (STR_INT_CMP(ver, 17, >)) {
|
||||
DM_ERR_RTN(0);
|
||||
}
|
||||
} else if (STR_CASE_CMP(stName, "CentOS Linux")) {
|
||||
} else if (STR_CASE_CMP(stName, dmOS[1])) {
|
||||
if (STR_INT_CMP(ver, 6, >)) {
|
||||
DM_ERR_RTN(0);
|
||||
}
|
||||
} else if (STR_STR_CMP(stName, "Red Hat") || STR_STR_CMP(stName, "Debian GNU") || STR_STR_CMP(stName, "CoreOS") ||
|
||||
STR_STR_CMP(stName, "FreeBSD") || STR_STR_CMP(stName, "openSUSE") || STR_STR_CMP(stName, "SLES") ||
|
||||
STR_STR_CMP(stName, "Fedora") || STR_STR_CMP(stName, "MacOS")) {
|
||||
} else if (STR_STR_CMP(stName, dmOS[2]) || STR_STR_CMP(stName, dmOS[3]) || STR_STR_CMP(stName, dmOS[4]) ||
|
||||
STR_STR_CMP(stName, dmOS[5]) || STR_STR_CMP(stName, dmOS[6]) || STR_STR_CMP(stName, dmOS[7]) ||
|
||||
STR_STR_CMP(stName, dmOS[8]) || STR_STR_CMP(stName, dmOS[9])) {
|
||||
DM_ERR_RTN(0);
|
||||
}
|
||||
|
||||
_exit:
|
||||
if (code != 0) {
|
||||
dError("failed to init monitor since %d", code);
|
||||
}
|
||||
if (code) terrno = code;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue