Merge pull request #26650 from taosdata/fix/TS-5178/udfEnv
fix: start udfd with env var
This commit is contained in:
commit
d4dceae3ce
|
@ -143,14 +143,29 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
||||||
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
udfdPathLdLib[udfdLdLibPathLen] = ':';
|
||||||
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
strncpy(udfdPathLdLib + udfdLdLibPathLen + 1, pathTaosdLdLib, sizeof(udfdPathLdLib) - udfdLdLibPathLen - 1);
|
||||||
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
if (udfdLdLibPathLen + taosdLdLibPathLen < 1024) {
|
||||||
fnInfo("udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
fnInfo("[UDFD]udfd LD_LIBRARY_PATH: %s", udfdPathLdLib);
|
||||||
} else {
|
} else {
|
||||||
fnError("can not set correct udfd LD_LIBRARY_PATH");
|
fnError("[UDFD]can not set correct udfd LD_LIBRARY_PATH");
|
||||||
}
|
}
|
||||||
char ldLibPathEnvItem[1024 + 32] = {0};
|
char ldLibPathEnvItem[1024 + 32] = {0};
|
||||||
snprintf(ldLibPathEnvItem, 1024 + 32, "%s=%s", "LD_LIBRARY_PATH", udfdPathLdLib);
|
snprintf(ldLibPathEnvItem, 1024 + 32, "%s=%s", "LD_LIBRARY_PATH", udfdPathLdLib);
|
||||||
|
|
||||||
char *envUdfd[] = {dnodeIdEnvItem, thrdPoolSizeEnvItem, ldLibPathEnvItem, NULL};
|
char *taosFqdnEnvItem = NULL;
|
||||||
|
char *taosFqdn = getenv("TAOS_FQDN");
|
||||||
|
if (taosFqdn != NULL) {
|
||||||
|
taosFqdnEnvItem = taosMemoryMalloc(strlen("TAOS_FQDN=") + strlen(taosFqdn) + 1);
|
||||||
|
if (taosFqdnEnvItem != NULL) {
|
||||||
|
strcpy(taosFqdnEnvItem, "TAOS_FQDN=");
|
||||||
|
strcat(taosFqdnEnvItem, taosFqdn);
|
||||||
|
fnInfo("[UDFD]Succsess to set TAOS_FQDN:%s", taosFqdn);
|
||||||
|
} else {
|
||||||
|
fnError("[UDFD]Failed to allocate memory for TAOS_FQDN");
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char *envUdfd[] = {dnodeIdEnvItem, thrdPoolSizeEnvItem, ldLibPathEnvItem,taosFqdnEnvItem, NULL};
|
||||||
|
|
||||||
options.env = envUdfd;
|
options.env = envUdfd;
|
||||||
|
|
||||||
int err = uv_spawn(&pData->loop, &pData->process, &options);
|
int err = uv_spawn(&pData->loop, &pData->process, &options);
|
||||||
|
@ -180,6 +195,7 @@ static int32_t udfSpawnUdfd(SUdfdData *pData) {
|
||||||
} else {
|
} else {
|
||||||
fnInfo("udfd is initialized");
|
fnInfo("udfd is initialized");
|
||||||
}
|
}
|
||||||
|
if(taosFqdnEnvItem) taosMemoryFree(taosFqdnEnvItem);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1421,22 +1421,26 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0) != 0) {
|
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 0) != 0) {
|
||||||
fnError("failed to start since read config error");
|
fnError("failed to start since read config error");
|
||||||
|
taosCloseLog();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
initEpSetFromCfg(tsFirst, tsSecond, &global.mgmtEp);
|
initEpSetFromCfg(tsFirst, tsSecond, &global.mgmtEp);
|
||||||
if (udfdOpenClientRpc() != 0) {
|
if (udfdOpenClientRpc() != 0) {
|
||||||
fnError("open rpc connection to mnode failed");
|
fnError("open rpc connection to mnode failed");
|
||||||
|
taosCloseLog();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (udfdCreateUdfSourceDir() != 0) {
|
if (udfdCreateUdfSourceDir() != 0) {
|
||||||
fnError("create udf source directory failed");
|
fnError("create udf source directory failed");
|
||||||
|
taosCloseLog();
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (udfdUvInit() != 0) {
|
if (udfdUvInit() != 0) {
|
||||||
fnError("uv init failure");
|
fnError("uv init failure");
|
||||||
|
taosCloseLog();
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1452,6 +1456,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
udfdDeinitScriptPlugins();
|
udfdDeinitScriptPlugins();
|
||||||
|
|
||||||
|
taosCloseLog();
|
||||||
udfdCleanup();
|
udfdCleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue