"Gracefully" exit when receiving sigint
This commit is contained in:
parent
02a5b0f7b9
commit
24e85f535a
2 changed files with 15 additions and 1 deletions
|
@ -17,3 +17,4 @@ RUN npx tsc
|
|||
|
||||
# Run the app
|
||||
CMD ["node", "dist/src/index.js"]
|
||||
STOPSIGNAL SIGINT
|
||||
|
|
15
src/index.ts
15
src/index.ts
|
@ -63,4 +63,17 @@ discord.on("messageCreate", message => {
|
|||
return queueRequest(message);
|
||||
});
|
||||
|
||||
if (require.main === module) void discord.login(config.tokens.Discord);
|
||||
if (require.main === module) {
|
||||
void discord.login(config.tokens.Discord);
|
||||
process.on("SIGINT", () => {
|
||||
console.log("got SIGINT, exiting");
|
||||
//FIXME: finish executing requests then exit
|
||||
discord.destroy()
|
||||
.then(() => process.exit())
|
||||
.catch((e) => {
|
||||
console.error("Failed to gracefully exit");
|
||||
console.error(e);
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue