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':