Gracefully shutdown Bot when App refreshes on changes


#1

Hello

Is there a possible entry point for when Glitch refreshes my app on changes. I do file stuff(asynchronously which I will change to synchronized, but I dont know if this helps my problem) and sometimes it happens that my files will become empty files because I assume in the middle of a write process Glitch just kills my process without giving it the chance to finish the writing. Happened two times yesterday all of a sudden btw.

So is there any possibility where I can do some stuff before my App is updated, like detecting a SIGTERM or is it enough if I synchronize my file writes and reads so that Glitch wont kill my App and refresh it until those are done?

Thank you.


#3

When the app refreshes, we send a SIGTERM to it. You can handle SIGTERM signals in your app: https://nodejs.org/api/process.html#process_signal_events


#4

Oh ok thank you Im new to nodejs stuff so thats helpful to now