Gracefully shutdown Bot when App refreshes on changes



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.


When the app refreshes, we send a SIGTERM to it. You can handle SIGTERM signals in your app:


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