Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
Properly handle sigterm (#223)
Browse files Browse the repository at this point in the history
* Properly await sigterm
Co-authored-by: noris alsaadie <>
  • Loading branch information
norisalsaadie authored Aug 17, 2020
1 parent 2f4636d commit 5402d9c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ const init = async (): Promise<void> => {
connection: config.db_connection,
});

const waitForServerClosure = async (server: Server): Promise<void> => {
return new Promise(resolve => {
server.close(() => resolve());
});
};

const shutDown = async (server: Server): Promise<void> => {
await knexConnection.destroy();
server.close(() => logger.info(`server closed`));
await waitForServerClosure(server);
process.exit();
};

Expand Down

0 comments on commit 5402d9c

Please sign in to comment.