Skip to content

Commit

Permalink
indicate os pid
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Sep 28, 2020
1 parent ec5665b commit de258ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,19 @@ function spawnWorker(type: 'server' | 'queue' | 'worker' = 'worker'): Promise<cl

// Listen new workers
cluster.on('fork', worker => {
clusterLogger.debug(`Process forked: [${worker.id}]`);
clusterLogger.debug(`Process forked: [${worker.id}:${worker.process.pid}]`);
});

// Listen online workers
cluster.on('online', worker => {
clusterLogger.debug(`Process is now online: [${worker.id}]`);
clusterLogger.debug(`Process is now online: [${worker.id}:${worker.process.pid}]`);
});

// Listen for dying workers
cluster.on('exit', worker => {
// Replace the dead worker,
// we're not sentimental
clusterLogger.error(chalk.red(`[${worker.id}] died :(`));
clusterLogger.error(chalk.red(`[${worker.id}:${worker.process.pid}] died :(`));
const type = workerIndex[worker.id] || 'worker';
const w = cluster.fork({ WORKER_TYPE: type });
workerIndex[w.id] = type;
Expand Down

0 comments on commit de258ad

Please sign in to comment.