End execution signal

Hi folks,

any way to catch a end execution signal? I want to save my ‘persisten’ data before system shutdown.


Hi @gunderwulde,

you can listen on SIGTERM, then you have 5 seconds to do all the clean up before the system forces a shutdown:

process.on("SIGTERM", function () {
  console.log("SIGTERM received, cleaning up...");

remember to call process.exit at the end of the SIGTERM handler. If you use async functions to persist the data, remember that you also need to call process.exit(0) asynchronously :slight_smile: .

1 Like

Damn, i forgot the process.exit!!!

Thanks etamponi,