mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
set workers to reduce their processing priority
This commit is contained in:
parent
cdcd4320a9
commit
e696a13fb2
@ -9,6 +9,7 @@ import { envOption } from "../env.js";
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { masterMain } from "./master.js";
|
import { masterMain } from "./master.js";
|
||||||
import { workerMain } from "./worker.js";
|
import { workerMain } from "./worker.js";
|
||||||
|
import os from "node:os";
|
||||||
|
|
||||||
const logger = new Logger("core", "cyan");
|
const logger = new Logger("core", "cyan");
|
||||||
const clusterLogger = logger.createSubLogger("cluster", "orange", false);
|
const clusterLogger = logger.createSubLogger("cluster", "orange", false);
|
||||||
@ -31,6 +32,16 @@ export default async function () {
|
|||||||
await workerMain();
|
await workerMain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cluster.isPrimary) {
|
||||||
|
// Leave the master process with a marginally lower priority but not too low.
|
||||||
|
os.setPriority(2);
|
||||||
|
}
|
||||||
|
if (cluster.isWorker) {
|
||||||
|
// Set workers to a much lower priority so that the master process will be
|
||||||
|
// able to respond to api calls even if the workers gank everything.
|
||||||
|
os.setPriority(10);
|
||||||
|
}
|
||||||
|
|
||||||
// For when Calckey is started in a child process during unit testing.
|
// For when Calckey is started in a child process during unit testing.
|
||||||
// Otherwise, process.send cannot be used, so start it.
|
// Otherwise, process.send cannot be used, so start it.
|
||||||
if (process.send) {
|
if (process.send) {
|
||||||
|
Loading…
Reference in New Issue
Block a user