From 2a492637979f1eb892c4a97bb46529afc11d0610 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sat, 7 Dec 2024 14:59:45 -0500 Subject: [PATCH] Add graceful shutdown --- src/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.js b/src/main.js index c9f9012..86fcfaf 100644 --- a/src/main.js +++ b/src/main.js @@ -135,6 +135,15 @@ process.comlink.on('feedRate', (message) => { } }); +process.on('SIGINT', () => { + fn.log(`Exiting gracefully...`, 'INFO'); + // Fail-safe to turn off all the outputs and keep the exhaust fan on + gpio.setPin(process.pinMap.get('auger').board, 0); + gpio.setPin(process.pinMap.get('igniter').board, 0); + gpio.setPin(process.pinMap.get('exhaust').board, 0); // Exhaust 0: On 1: Off + process.exit(); +}); + /***************************************************************************************/ // Call Things /***************************************************************************************/