Add way to exit script

This commit is contained in:
Skylar Grant 2023-01-06 21:19:57 -05:00
parent d7a32e18ce
commit f37ff53bb6
1 changed files with 11 additions and 1 deletions

View File

@ -14,7 +14,7 @@ config.timestamps.procStart = Date.now();
const dotenv = require('dotenv').config();
// Module for working with files
const fs = require('fs');
const { time } = require('console');
const { exec } = require('child_process');
const main = (gpio) => {
functions.commands.refreshConfig().then(res => {
@ -170,6 +170,16 @@ const functions = {
});
})
},
quit() {
functions.commands.shutdown();
functions.auger.off(gpio).then(res => {
console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: Exiting app...`);
process.exit(0);
}).catch(err => {
console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: Unable to shut off auger, rebooting Pi!`);
exec('shutdown -r 0');
});
}
},
// Sleeps for any given milliseconds