Add way to exit script
This commit is contained in:
parent
d7a32e18ce
commit
f37ff53bb6
12
functions.js
12
functions.js
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user