Skip to content

Commit 68d37be

Browse files
committed
gracefully exit for --watch
1 parent b30268e commit 68d37be

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

apps/browser-proxy/src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,22 @@ httpsServer.listen(443, () => {
1616
tcpServer.listen(5432, () => {
1717
console.log('tcp server listening on port 5432')
1818
})
19+
20+
const shutdown = async () => {
21+
await Promise.allSettled([
22+
new Promise<void>((res) =>
23+
httpsServer.close(() => {
24+
res()
25+
})
26+
),
27+
new Promise<void>((res) =>
28+
tcpServer.close(() => {
29+
res()
30+
})
31+
),
32+
])
33+
process.exit(0)
34+
}
35+
36+
process.on('SIGTERM', shutdown)
37+
process.on('SIGINT', shutdown)

0 commit comments

Comments
 (0)