View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/578 Closes #586 Approved-by: Tess K <me@thvxl.se> Approved-by: Marie <marie@kaifa.ch>
This commit is contained in:
commit
5496aa27db
1 changed files with 9 additions and 1 deletions
|
@ -112,6 +112,11 @@ export async function masterMain() {
|
|||
await server();
|
||||
}
|
||||
|
||||
if (config.clusterLimit === 0) {
|
||||
bootLogger.error("Configuration error: we can't create workers, `config.clusterLimit` is 0 (if you don't want to use clustering, set the environment variable `MK_DISABLE_CLUSTERING` to a non-empty value instead)", null, true);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
await spawnWorkers(config.clusterLimit);
|
||||
}
|
||||
|
||||
|
@ -180,7 +185,10 @@ async function connectDb(): Promise<void> {
|
|||
*/
|
||||
|
||||
async function spawnWorkers(limit = 1) {
|
||||
const workers = Math.min(limit, os.cpus().length);
|
||||
const cpuCount = os.cpus().length;
|
||||
// in some weird environments, node can't count the CPUs; we trust the config in those cases
|
||||
const workers = cpuCount === 0 ? limit : Math.min(limit, cpuCount);
|
||||
|
||||
bootLogger.info(`Starting ${workers} worker${workers === 1 ? '' : 's'}...`);
|
||||
await Promise.all([...Array(workers)].map(spawnWorker));
|
||||
bootLogger.succ('All workers started');
|
||||
|
|
Loading…
Reference in a new issue