forked from FoundKeyGang/FoundKey
refactor: use switch for receiving IPC messages
This commit is contained in:
parent
ac81acfe9d
commit
e6c7f4b693
1 changed files with 8 additions and 5 deletions
|
@ -160,12 +160,15 @@ function spawnWorker(mode: 'web' | 'queue'): Promise<void> {
|
||||||
return new Promise(res => {
|
return new Promise(res => {
|
||||||
const worker = cluster.fork({ mode });
|
const worker = cluster.fork({ mode });
|
||||||
worker.on('message', message => {
|
worker.on('message', message => {
|
||||||
if (message === 'listenFailed') {
|
switch (message) {
|
||||||
|
case 'listenFailed':
|
||||||
bootLogger.error('The server Listen failed due to the previous error.');
|
bootLogger.error('The server Listen failed due to the previous error.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
break;
|
||||||
if (message !== 'ready') return;
|
case 'ready':
|
||||||
res();
|
res();
|
||||||
|
break;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue