Adjust the log stack for the cleanup

This commit is contained in:
Oliver-Akins 2020-10-06 23:18:09 -06:00
parent d4d01bf3ac
commit d49b214762

View file

@ -35,13 +35,15 @@ const db_dir = `data`;
* whatever reason. It cleans up and writes all the active games to the disk. * whatever reason. It cleans up and writes all the active games to the disk.
*/ */
function clean_up() { function clean_up() {
log.info(`Cleaning up games...`);
for (var code in active_games) { for (var code in active_games) {
console.log(`Writing game: ${code} to disk`); log.debug(`Writing game: ${code} to disk`);
writeFileSync(`${db_dir}/${code}`, active_games[code].toJSON()); log.silly(active_games[code]);
// writeFileSync(`${db_dir}/${code}`, active_games[code].toJSON());
}; };
log.info(`Finished saving games to disk.`); log.info(`Finished cleanup. Exiting.`);
process.exit(0); process.exit(0);
} };
// Listen to the signals for the cleanup requirement // Listen to the signals for the cleanup requirement
process.on(`uncaughtException`, clean_up); process.on(`uncaughtException`, clean_up);