Skip to content

Commit e63a83d

Browse files
authored
fix: random exit from worker making server not react
1 parent 16caf33 commit e63a83d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ if (cluster.isPrimary) {
2727
// create the workers
2828
console.log(`creating ${maxWorkers} workers...`)
2929
for (let i = 0; i < maxWorkers; i++) {
30-
cluster.fork();
30+
cluster.fork()
3131
}
3232

3333
cluster.on('online', (worker) => {
3434
console.log('Worker', worker.id, 'online')
3535
})
3636

37-
cluster.on("exit", (worker, code, _signal) => {
38-
console.log(`Worker ${worker.id} exited with code ${code}`);
37+
cluster.on("exit", (worker, code, signal) => {
38+
console.log(`Worker ${worker.id} exited with code ${code} and signal ${signal}`);
39+
cluster.fork()
3940
})
4041
console.log('🚀 Server ready at localhost:3000');
4142
} else {

0 commit comments

Comments
 (0)