Skip to content

Commit

Permalink
Merge pull request #24 from oasysgames/feature/modify_app_build
Browse files Browse the repository at this point in the history
Feature/modify app build
  • Loading branch information
Tsuyoshi-Ishikawa authored Apr 24, 2023
2 parents b864560 + 32cbb4d commit fc1b97c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as _cluster from 'cluster';
import { cpus } from 'os';

const cluster = _cluster as unknown as _cluster.Cluster;
const workerCount = process.env.CLUSTER_PROCESS
let workerCount = process.env.CLUSTER_PROCESS
? parseInt(process.env.CLUSTER_PROCESS, 10)
: 1;

Expand All @@ -30,10 +30,13 @@ async function bootstrap() {

if (cluster.isPrimary) {
const workerLimit = cpus().length;
if (workerCount > workerLimit)
throw new Error(
`cluster process limit is ${workerLimit}. CLUSTER_PROCESS is over ${workerLimit}`,

if (workerCount > workerLimit) {
console.warn(
`cluster process limit is ${workerLimit}. cluster process count is set to ${workerLimit}.`,
);
workerCount = workerLimit;
}

for (let i = 0; i < workerCount; i++) {
console.log('cluster fork :', i);
Expand Down

0 comments on commit fc1b97c

Please sign in to comment.