diff --git a/server/src/main.ts b/server/src/main.ts index 7b38cfd..e0147df 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -4,6 +4,7 @@ import { readFileSync } from "fs"; import { Game } from "./objects/Game"; import startWebsocket from "./websocket"; import { Validate } from "./utils/validate"; +import { processExit } from "./utils/cleanup"; export const conf: config = toml.parse(readFileSync(`server.toml`, `utf-8`)); @@ -18,6 +19,17 @@ export const log: Logger = new Logger({ name: `GLOBAL`, }); +// Ensure the config valid if (Validate.config(conf)) { + + // Add event listeners if we want to use the datastore saving game system + if (conf.datastores.enabled) { + + // Get games from datastore + + process.on(`uncaughtException`, processExit); + process.on(`SIGINT`, processExit); + }; + startWebsocket(conf); } \ No newline at end of file