Sunday, 16 April 2017

Node script does not exit properly when it's running as cron job

I am trying to use this node script (FP2DOM.js).

If I run manually from terminal, the script is always terminating correctly.

If I run as a cron job:

*/15 * * * * node /root/domoticz-flower-power/FP2DOM.js a0143d7d9338 >/root/domoticz-flower-power.log

The script does not exit when it's done, and another cron job creates new instance. So every cron job creates new node instance.

The node script contains process.exit(0);, so I don't really understand why it's not exiting correctly, when running as a cron job.

One workaround is to:

*/15 * * * * killall node; node /root/domoticz-flower-power/FP2DOM.js a0143d7d9338 >/root/domoticz-flower-power.log

...but in this case I can't run another node scripts, for obvious reasons.



via Adrian

No comments:

Post a Comment