Skip to content

Commit

Permalink
rotor: fix for graceful shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Nov 24, 2023
1 parent 7593136 commit cf90abd
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions services/rotor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,24 +372,15 @@ async function main() {

errorTypes.forEach(type => {
process.on(type, async err => {
try {
log.atError().withCause(err).log(`process.on ${type}`);
await rotor.close();
process.exit(1);
} catch (_) {
process.exit(1);
}
log.atError().withCause(err).log(`process.on ${type}`);
await rotor.close().finally(() => process.exit(1));
});
});

signalTraps.forEach(type => {
process.once(type, async () => {
try {
log.atInfo().log(`Signal ${type} received`);
await rotor.close();
} finally {
process.kill(process.pid, type);
}
log.atInfo().log(`Signal ${type} received`);
await rotor.close().finally(() => process.kill(process.pid, type));
});
});
}
Expand Down

0 comments on commit cf90abd

Please sign in to comment.