From 0b6794fb8909b634da0c02e5e4cec637517c3d18 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Mon, 13 Nov 2023 18:41:55 -0500 Subject: [PATCH] Fixed startup failure bug --- main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.js b/main.js index 5cc9179..9ff12ef 100644 --- a/main.js +++ b/main.js @@ -9,9 +9,15 @@ portal.start(); dbfn.run(`UPDATE timestamps SET value = ${Date.now()} WHERE key = 'process_start'`).catch(err => console.error(`Error setting process start time: ${err}`)); +// Initialization, which then calls main() fn.commands.refreshConfig().then(res => { if (process.env.DEBUG) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: ${res.status}`); config = res.config; + const shutdownNextCycleQuery = "UPDATE status SET value = 0 WHERE key = 'shutdown_next_cycle'"; + dbfn.run(shutdownNextCycleQuery).then(res => { + if (process.env.DEBUG) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: ${res.status}`); + console.log(`[${(Date.now() - config.timestamps.procStart) / 1000}] I: Shutdown flag reset.`); + }).catch(err => console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`)); // Setup for use with the Pi's GPIO pins switch (process.env.ONPI) { case 'true':