How to detect changes when running Node on Balena

I’m building a Node project on a raspberry pi 3, running Node.js v12.

When I push to my local raspberry pi (in dev mode), whenever I change the code, the changes are automatically synced i.e. the service restarts.

My question is: Is it possible to run some code, before this happens?

I currently listen to the SIGINT, but this does not seem to be called on service restart.

process.on("SIGINT", _ => {

As a workaround I could maybe call the cleanup scripts on restart?

Hi, SIGINT is called when you press ctrl-c in the terminal. I think you need to listen for SIGTERM. For other reasons why you may not be able to catch a signal:

I updated to use SIGTERM, but I still just get this: [Live] Detected changes for container main, updating...

Appears that there is a bug in livepush that sends SIGKILL signal directly ( This will not be the case when running production version of balenaos.