Add cleanup listeners if they are enabled.
This commit is contained in:
parent
7914ff7e45
commit
f0f3032465
1 changed files with 12 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import { readFileSync } from "fs";
|
||||||
import { Game } from "./objects/Game";
|
import { Game } from "./objects/Game";
|
||||||
import startWebsocket from "./websocket";
|
import startWebsocket from "./websocket";
|
||||||
import { Validate } from "./utils/validate";
|
import { Validate } from "./utils/validate";
|
||||||
|
import { processExit } from "./utils/cleanup";
|
||||||
|
|
||||||
export const conf: config = toml.parse(readFileSync(`server.toml`, `utf-8`));
|
export const conf: config = toml.parse(readFileSync(`server.toml`, `utf-8`));
|
||||||
|
|
||||||
|
|
@ -18,6 +19,17 @@ export const log: Logger = new Logger({
|
||||||
name: `GLOBAL`,
|
name: `GLOBAL`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ensure the config valid
|
||||||
if (Validate.config(conf)) {
|
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);
|
startWebsocket(conf);
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue