feat: allow horizontal scaling

This commit is contained in:
April John 2023-05-17 00:08:14 +02:00
parent 3897adaed7
commit 6a5b9009f0
4 changed files with 11 additions and 3 deletions

View file

@ -124,6 +124,9 @@ reservedUsernames: [
# Number of worker processes
#clusterLimit: 1
# Worker only mode
#onlyQueueProcessor: 1
# Job concurrency per worker
# deliverJobConcurrency: 128
# inboxJobConcurrency: 16

View file

@ -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());

View file

@ -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());

View file

@ -52,6 +52,8 @@ export type Source = {
clusterLimit?: number;
onlyQueueProcessor?: boolean;
id: string;
outgoingAddressFamily?: "ipv4" | "ipv6" | "dual";