Skip to content

Commit

Permalink
Optional Workers: (getcord#24)
Browse files Browse the repository at this point in the history
- Make Admin and Console workers optional via env variable
  • Loading branch information
Antonio-RiveroMartnez authored Sep 3, 2024
1 parent f40c5d3 commit f6ca50d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions scripts/generate-dotenv.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
6 changes: 6 additions & 0 deletions server/src/config/Env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
4 changes: 2 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down Expand Up @@ -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.)
Expand Down

0 comments on commit f6ca50d

Please sign in to comment.