Skip to content

best way to save what you love

api: set up env watcher only after cluster is initialized

jj212b07394d9f
diff --git a/api/src/cobalt.js b/api/src/cobalt.js
index 5cac208d..cf531297 100644
--- a/api/src/cobalt.js
+++ b/api/src/cobalt.js
@@ -9,6 +9,7 @@ import { fileURLToPath } from "url";
import { env, isCluster } from "./config.js"
import { Red } from "./misc/console-text.js";
import { initCluster } from "./misc/cluster.js";
+import { setupEnvWatcher } from "./core/env.js";
const app = express();
@@ -24,6 +25,10 @@ if (env.apiURL) {
await initCluster();
}
+ if (env.envFile) {
+ setupEnvWatcher();
+ }
+
runAPI(express, app, __dirname, cluster.isPrimary);
} else {
console.log(
diff --git a/api/src/config.js b/api/src/config.js
index ceac2f6d..8f1579b8 100644
--- a/api/src/config.js
+++ b/api/src/config.js
@@ -1,5 +1,5 @@
import { getVersion } from "@imput/version-info";
-import { loadEnvs, validateEnvs, setupEnvWatcher } from "./core/env.js";
+import { loadEnvs, validateEnvs } from "./core/env.js";
const version = await getVersion();
@@ -29,10 +29,6 @@ export const updateEnv = (newEnv) => {
await validateEnvs(env);
-if (env.envFile) {
- setupEnvWatcher();
-}
-
export {
env,
genericUserAgent,