From 48aa89f7cf07aba80160e6f6b36be7c2db11ec7b Mon Sep 17 00:00:00 2001 From: Darren Clarke Date: Tue, 5 Nov 2024 10:12:18 +0100 Subject: [PATCH] Make bridge worker settings configuration via env vars --- apps/bridge-worker/graphile.config.ts | 8 ++++++-- apps/bridge-worker/index.ts | 13 ++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/bridge-worker/graphile.config.ts b/apps/bridge-worker/graphile.config.ts index 8b550c7..9367a65 100644 --- a/apps/bridge-worker/graphile.config.ts +++ b/apps/bridge-worker/graphile.config.ts @@ -4,8 +4,12 @@ import type {} from "graphile-worker"; const preset: GraphileConfig.Preset = { worker: { connectionString: process.env.DATABASE_URL, - maxPoolSize: 10, - pollInterval: 2000, + maxPoolSize: process.env.BRIDGE_WORKER_POOL_SIZE + ? parseInt(process.env.BRIDGE_WORKER_POOL_SIZE, 10) + : 10, + pollInterval: process.env.BRIDGE_WORKER_POLL_INTERVAL + ? parseInt(process.env.BRIDGE_WORKER_POLL_INTERVAL, 10) + : 2000, fileExtensions: [".ts"], }, }; diff --git a/apps/bridge-worker/index.ts b/apps/bridge-worker/index.ts index 5a7dbd5..0101b96 100644 --- a/apps/bridge-worker/index.ts +++ b/apps/bridge-worker/index.ts @@ -7,12 +7,19 @@ const __dirname = path.dirname(__filename); const startWorker = async () => { console.log("Starting worker..."); - console.log(process.env); + await run({ connectionString: process.env.DATABASE_URL, - concurrency: 10, noHandleSignals: false, - pollInterval: 1000, + concurrency: process.env.BRIDGE_WORKER_CONCURRENCY + ? parseInt(process.env.BRIDGE_WORKER_CONCURRENCY, 10) + : 10, + maxPoolSize: process.env.BRIDGE_WORKER_POOL_SIZE + ? parseInt(process.env.BRIDGE_WORKER_POOL_SIZE, 10) + : 10, + pollInterval: process.env.BRIDGE_WORKER_POLL_INTERVAL + ? parseInt(process.env.BRIDGE_WORKER_POLL_INTERVAL, 10) + : 1000, taskDirectory: `${__dirname}/tasks`, crontabFile: `${__dirname}/crontab`, });