Add event listeners for cleanup
This commit is contained in:
parent
729f6b7cd5
commit
c2e28ce14b
1 changed files with 6 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import * as sio from "socket.io";
|
||||
import { writeFileSync } from "fs";
|
||||
import { Vote } from "./events/Vote";
|
||||
import { JoinGame } from "./events/JoinGame";
|
||||
import { HostGame } from "./events/HostGame";
|
||||
|
|
@ -30,6 +31,11 @@ function clean_up() {
|
|||
};
|
||||
console.log(`Finished saving games to disk.`);
|
||||
}
|
||||
|
||||
// Listen to the signals for the cleanup requirement
|
||||
process.on(`uncaughtException`, clean_up);
|
||||
process.on('SIGINT', clean_up);
|
||||
|
||||
const io = sio.listen(3000);
|
||||
|
||||
io.on(`connection`, (socket: sio.Socket) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue