mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-06-07 13:49:54 +00:00
feat: Allow to customize number of workers (#616)
This commit is contained in:
parent
c52ed815bb
commit
ebc2bb28bf
@ -7,11 +7,19 @@ import jsonEndpoints from './V2/endpoints/jsonEndpoints'
|
|||||||
import graphql from './V2/graphql'
|
import graphql from './V2/graphql'
|
||||||
|
|
||||||
if (cluster.isPrimary) {
|
if (cluster.isPrimary) {
|
||||||
console.log(`Primary ${process.pid} is running`);
|
console.log(`Primary ${process.pid} is running`)
|
||||||
|
|
||||||
const parallelism = availableParallelism()
|
// get maximum number of workers available for the software
|
||||||
console.log(`creating ${parallelism} workers...`)
|
let maxWorkers = availableParallelism()
|
||||||
for (let i = 0; i < parallelism; i++) {
|
|
||||||
|
// allow to override max worker count
|
||||||
|
if (process.env.MAX_WORKERS) {
|
||||||
|
maxWorkers = Math.min(parallelism, parseInt(process.env.MAX_WORKERS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the workers
|
||||||
|
console.log(`creating ${maxWorkers} workers...`)
|
||||||
|
for (let i = 0; i < maxWorkers; i++) {
|
||||||
cluster.fork();
|
cluster.fork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user