From: Laurent Mazet Date: Wed, 29 Apr 2020 06:15:32 +0000 (+0200) Subject: Allow setting the path to the games backup in the server X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=01d13f4decfb805beeb3bbb6830844dcb99b26e2;p=trivabble.git Allow setting the path to the games backup in the server --- diff --git a/trivabble-server.js b/trivabble-server.js index 8b6fda2..6f511e3 100644 --- a/trivabble-server.js +++ b/trivabble-server.js @@ -30,6 +30,7 @@ const port = parseInt(process.env.TRIVABBLE_PORT || "3000"); const SAVE_TIMEOUT = 5000; const KEEP_ALIVE = 30000; +const GAMES_BACKUP = process.env.TRIVABBLE_GAMES_BACKUP || "games.backup.json"; const VERSION = 202004281800; @@ -126,7 +127,7 @@ const server = http.createServer(handleRequest); server.setTimeout(0); // The default in node 13 is 0. Earlier versions have 120. function saveGames(callback) { - fs.writeFile("games.backup.json", JSON.stringify(games), function (err) { + fs.writeFile(GAMES_BACKUP, JSON.stringify(games), function (err) { if (err) { console.error("ERROR: Cannot save games!"); } @@ -1040,7 +1041,7 @@ function handleRequest(request, response) { }); } -fs.readFile("games.backup.json", function (err, data) { +fs.readFile(GAMES_BACKUP, function (err, data) { try { if (err) { console.error("WARNING: Could not restore previous backup of the games");