diff --git a/.config/example.yml b/.config/example.yml index e37d53504..7d8ba32be 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -124,6 +124,9 @@ reservedUsernames: [ # Number of worker processes #clusterLimit: 1 +# Worker only mode +#onlyQueueProcessor: 1 + # Job concurrency per worker # deliverJobConcurrency: 128 # inboxJobConcurrency: 16 diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 193f02429..f22fafb5a 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -93,7 +93,7 @@ export async function masterMain() { true, ); - if (!envOption.noDaemons) { + if (!envOption.noDaemons && !config.onlyQueueProcessor) { import("../daemons/server-stats.js").then((x) => x.default()); import("../daemons/queue-stats.js").then((x) => x.default()); import("../daemons/janitor.js").then((x) => x.default()); diff --git a/packages/backend/src/boot/worker.ts b/packages/backend/src/boot/worker.ts index 70442b096..052c7397f 100644 --- a/packages/backend/src/boot/worker.ts +++ b/packages/backend/src/boot/worker.ts @@ -1,5 +1,6 @@ import cluster from "node:cluster"; import { initDb } from "../db/postgre.js"; +import config from "@/config/index.js"; /** * Init worker process @@ -7,8 +8,10 @@ import { initDb } from "../db/postgre.js"; export async function workerMain() { await initDb(); - // start server - await import("../server/index.js").then((x) => x.default()); + if (!config.onlyQueueProcessor) { + // start server + await import("../server/index.js").then((x) => x.default()); + } // start job queue import("../queue/index.js").then((x) => x.default()); diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 0cd8c02ad..01a98f9f0 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -52,6 +52,8 @@ export type Source = { clusterLimit?: number; + onlyQueueProcessor?: boolean; + id: string; outgoingAddressFamily?: "ipv4" | "ipv6" | "dual";