Skip to content

Commit

Permalink
fix(rest-api-server): wait for teardown operations to finish
Browse files Browse the repository at this point in the history
  • Loading branch information
PJColombo committed Jun 14, 2024
1 parent e74971f commit 3d3299f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/rest-api-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ async function gracefulShutdown(signal: string) {
logger.debug(`Received ${signal}. Shutting down...`);

await apiGracefulShutdown()
.finally(() => closeSyncers())
.finally(async () => {
await closeSyncers();
})
.finally(() => {
server.close(() => {
logger.debug("Server shut down successfully");
Expand All @@ -70,7 +72,11 @@ async function gracefulShutdown(signal: string) {
}

// Listen for TERM signal .e.g. kill
process.on("SIGTERM", () => void gracefulShutdown("SIGTERM"));
process.on("SIGTERM", async () => {
await gracefulShutdown("SIGTERM");
});

// Listen for INT signal e.g. Ctrl-C
process.on("SIGINT", () => void gracefulShutdown("SIGINT"));
process.on("SIGINT", async () => {
await gracefulShutdown("SIGINT");
});

0 comments on commit 3d3299f

Please sign in to comment.