diff --git a/src/main.ts b/src/main.ts index 16064cc..3432fd7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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) => {