Skip to content

Commit 40f573e

Browse files
committed
PEER-220: Add WS shutdown
Signed-off-by: SeeuSim <[email protected]>
1 parent 3f2865a commit 40f573e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

backend/matching/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ChildProcess } from 'child_process';
22

33
import { EXPRESS_PORT } from '@/config';
44
import { logger } from '@/lib/utils';
5-
import server from '@/server';
5+
import server, { io } from '@/server';
66
import { initWorker } from '@/workers';
77

88
const workers: ChildProcess[] = [];
@@ -19,11 +19,13 @@ const shutdown = () => {
1919
workers.forEach((worker) => {
2020
worker.kill();
2121
});
22+
io.close(() => {
23+
logger.info('WS Server shut down');
24+
});
2225
server.close(() => {
2326
logger.info('App shut down');
2427
});
2528
};
2629

2730
process.on('SIGINT', shutdown);
2831
process.on('SIGTERM', shutdown);
29-
process.on('exit', shutdown);

backend/matching/src/workers/cleaner.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const shutdown = () => {
2525
};
2626

2727
process.on('SIGINT', shutdown);
28-
process.on('SIGHUP', shutdown);
2928
process.on('SIGTERM', shutdown);
3029

3130
async function clean() {

backend/matching/src/workers/matcher.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const shutdown = () => {
2525
};
2626

2727
process.on('SIGINT', shutdown);
28-
process.on('SIGHUP', shutdown);
2928
process.on('SIGTERM', shutdown);
3029

3130
type RequestorParams = {

0 commit comments

Comments
 (0)