openrowingmonitor
openrowingmonitor copied to clipboard
Pigpio startup error
Sometimes when I do frequent restart of the app I get pigpio initialize error. ˙
2023-01-01 17:40:12 initInitialise: Can't lock /var/run/pigpio.pid
/opt/openrowingmonitor/node_modules/pigpio/pigpio.js:54
pigpio.gpioInitialise();
^
Error: pigpio error -1 in gpioInitialise
at initializePigpio (/opt/openrowingmonitor/node_modules/pigpio/pigpio.js:54:12)
at new Gpio (/opt/openrowingmonitor/node_modules/pigpio/pigpio.js:158:5)
at createGpioTimerService (file:///opt/openrowingmonitor/app/gpio/GpioTimerService.js:40:18)
at file:///opt/openrowingmonitor/app/gpio/GpioTimerService.js:69:1
Based on some research this may be due to pigpio not shutting down cleanly. The recommendation is add a listener to the process exit codes where the pigpio.terminate()
should be called:
process.on('SIGHUP', shutdown)
process.on('SIGINT', shutdown)
process.on('SIGCONT', shutdown)
process.on('SIGTERM', shutdown)
function shutdown () {
pigpio.terminate()
process.exit(0)
}
Has anyone encountered this issue?