Skip to content

Commit

Permalink
fix: force exit on SIGINT/SIGTERM (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonychu authored Apr 4, 2021
1 parent 7b67cf8 commit 41fadea
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/proxy/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ const requestHandler = (userConfig: SWAConfigFile | null) =>
server.on("upgrade", onWsUpgrade);

registerProcessExit(() => {
const timeout = setTimeout(() => process.exit(0), 2000);
socketConnection?.end(() => logger.info("WebSocket connection closed."));
server.close(() => logger.log("Server stopped."));
proxyApi.close();
proxyApp.close();
clearTimeout(timeout);
});
};

Expand Down

0 comments on commit 41fadea

Please sign in to comment.