mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 18:07:31 -07:00
feat: allow horizontal scaling
This commit is contained in:
parent
2310f772f2
commit
5752cdb742
4 changed files with 11 additions and 3 deletions
|
@ -124,6 +124,9 @@ reservedUsernames: [
|
||||||
# Number of worker processes
|
# Number of worker processes
|
||||||
#clusterLimit: 1
|
#clusterLimit: 1
|
||||||
|
|
||||||
|
# Worker only mode
|
||||||
|
#onlyQueueProcessor: 1
|
||||||
|
|
||||||
# Job concurrency per worker
|
# Job concurrency per worker
|
||||||
# deliverJobConcurrency: 128
|
# deliverJobConcurrency: 128
|
||||||
# inboxJobConcurrency: 16
|
# inboxJobConcurrency: 16
|
||||||
|
|
|
@ -93,7 +93,7 @@ export async function masterMain() {
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!envOption.noDaemons) {
|
if (!envOption.noDaemons && !config.onlyQueueProcessor) {
|
||||||
import("../daemons/server-stats.js").then((x) => x.default());
|
import("../daemons/server-stats.js").then((x) => x.default());
|
||||||
import("../daemons/queue-stats.js").then((x) => x.default());
|
import("../daemons/queue-stats.js").then((x) => x.default());
|
||||||
import("../daemons/janitor.js").then((x) => x.default());
|
import("../daemons/janitor.js").then((x) => x.default());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import cluster from "node:cluster";
|
import cluster from "node:cluster";
|
||||||
import { initDb } from "../db/postgre.js";
|
import { initDb } from "../db/postgre.js";
|
||||||
|
import config from "@/config/index.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init worker process
|
* Init worker process
|
||||||
|
@ -7,8 +8,10 @@ import { initDb } from "../db/postgre.js";
|
||||||
export async function workerMain() {
|
export async function workerMain() {
|
||||||
await initDb();
|
await initDb();
|
||||||
|
|
||||||
|
if (!config.onlyQueueProcessor) {
|
||||||
// start server
|
// start server
|
||||||
await import("../server/index.js").then((x) => x.default());
|
await import("../server/index.js").then((x) => x.default());
|
||||||
|
}
|
||||||
|
|
||||||
// start job queue
|
// start job queue
|
||||||
import("../queue/index.js").then((x) => x.default());
|
import("../queue/index.js").then((x) => x.default());
|
||||||
|
|
|
@ -52,6 +52,8 @@ export type Source = {
|
||||||
|
|
||||||
clusterLimit?: number;
|
clusterLimit?: number;
|
||||||
|
|
||||||
|
onlyQueueProcessor?: boolean;
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
outgoingAddressFamily?: "ipv4" | "ipv6" | "dual";
|
outgoingAddressFamily?: "ipv4" | "ipv6" | "dual";
|
||||||
|
|
Loading…
Reference in a new issue