From f6ca50d7d6a95f54566391ec66992be09ccc19b7 Mon Sep 17 00:00:00 2001 From: Antonio Rivero <38889534+Antonio-RiveroMartnez@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:04:58 +0200 Subject: [PATCH] Optional Workers: (#24) - Make Admin and Console workers optional via env variable --- scripts/generate-dotenv.cjs | 2 ++ server/src/config/Env.ts | 6 ++++++ server/src/server.ts | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/generate-dotenv.cjs b/scripts/generate-dotenv.cjs index 31a5c611d..352b8b177 100755 --- a/scripts/generate-dotenv.cjs +++ b/scripts/generate-dotenv.cjs @@ -206,6 +206,8 @@ function buildProdEnv(commitHash) { DEMO_APPS_SHARED_SECRET: secrets.DEMO_APPS_SHARED_SECRET.key, LOOPS_SO_API_KEY: secrets.LOOPS_SO_API_KEY.api_key, PYROSCOPE_ENDPOINT: 'http://monitoring.int.cord.com:4040', + IGNORE_ADMIN_SERVER_WORKER: false, + IGNORE_CONSOLE_SERVER_WORKER: false, }; } diff --git a/server/src/config/Env.ts b/server/src/config/Env.ts index ab24bfe31..33b646afb 100644 --- a/server/src/config/Env.ts +++ b/server/src/config/Env.ts @@ -233,4 +233,10 @@ export default magicEnv(process.env, { // loops.so for sending newletters LOOPS_SO_API_KEY: required, + + // Make Admin Server Optional + IGNORE_ADMIN_SERVER_WORKER: optional, + + // Make Admin Server Optional + IGNORE_CONSOLE_SERVER_WORKER: optional, }); diff --git a/server/src/server.ts b/server/src/server.ts index 76702c61f..02ba3c301 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -180,7 +180,7 @@ async function main() { // ------------------------------------------------------------------------- // ADMIN - if (isSingleProcessOrMaster || workerType === 'admin') { + if (!env.IGNORE_ADMIN_SERVER_WORKER && (isSingleProcessOrMaster || workerType === 'admin')) { // Either we are not in cluster mode, or this process is the master or an // 'admin' worker. (If this is a worker process of a different type, we skip // this section.) @@ -210,7 +210,7 @@ async function main() { // ------------------------------------------------------------------------- // CONSOLE - if (isSingleProcessOrMaster || workerType === 'console') { + if (!env.IGNORE_CONSOLE_SERVER_WORKER && (isSingleProcessOrMaster || workerType === 'console')) { // Either we are not in cluster mode, or this process is the master or an // 'console' worker. (If this is a worker process of a different type, we skip // this section.)