Add capacity for worker processes
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import cluster from 'node:cluster'
|
||||
import os from 'node:os'
|
||||
import process from 'node:process'
|
||||
import { log } from "./util";
|
||||
import { env, log } from "./util";
|
||||
|
||||
if (cluster.isPrimary) {
|
||||
const n = os.availableParallelism();
|
||||
const n = Math.min(os.availableParallelism(), +env.MAX_WORKER_PROCESSES);
|
||||
log.info(`Starting ${n} worker processes`)
|
||||
for (let i = 0; i < n; i++)
|
||||
cluster.fork()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type Selectable, type Transaction } from "kysely";
|
||||
import type { DB, JsonValue } from "../database/out/db";
|
||||
import type { DB } from "../database/out/db";
|
||||
import { log } from "../util";
|
||||
import { sleep } from "bun";
|
||||
import { db } from "../database/db";
|
||||
|
||||
@@ -19,6 +19,7 @@ export const env = {
|
||||
AUTH_SECRET: requireEnv("AUTH_SECRET"),
|
||||
ADMIN_PASSWORD: requireEnv("ADMIN_PASSWORD"),
|
||||
DATABASE_URL: requireEnv("DATABASE_URL"),
|
||||
MAX_WORKER_PROCESSES: requireEnv("MAX_WORKER_PROCESSES"),
|
||||
NODE_ENV: optionEnv("NODE_ENV", "development"),
|
||||
LOG_LEVEL: optionEnv("LOG_LEVEL", "info"),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user