I'm running a Node.js application that is doing some GPIO work. If any sort of error occurs or the user closes the application with CTRL + C
I'm currently handling it. One scenario I can't catch though is when I disconnect my SSH session by closing my SSH client.
Closing my SSH client is killing the Node.js application (which is fine) but there are certain GPIO cleanup methods that need to happen before it closes.
These are the events I've tried and none of them are catching when SSH closes:
var cleanup = () => { /*cleanup code*/ };
var domain = require('domain').create();
domain.on('error', cleanup);
process.on('uncaughtException', cleanup);
process.on('SIGINT', cleanup);
process.on('SIGTERM', cleanup);
process.on('exit', cleanup);
process.on('unhandledRejection', cleanup);
process.on('disconnect', cleanup);
process.on('SIGUSR1', cleanup);
process.on('SIGUSR2', cleanup);
process.on('beforeExit', cleanup);
What event emits when an app is closing due to an SSH session terminating?