alexb
December 9, 2019, 10:23am
1
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", _ => {
cleanupLcd();
cleanupRotaryEncoder();
process.exit();
});
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: https://hynek.me/articles/docker-signals/
alexb
December 9, 2019, 10:49am
4
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 (https://github.com/balena-io-modules/livepush/issues/49 ). This will not be the case when running production version of balenaos.