After installing and setting up node.js on my development VM running Ubuntu 11.10, I would like supervisor to start automatically on boot, calling and reloading node.js when needed.
Below snippet works well when ran by my default user in terminal, but how can I get it to run on boot?
cd /var/ && supervisor -w www www/myapp/app.js
Thanks
Upstart plus monit works quite well to get everything running at boot time and keep node processes up. Plus you can use npm to install them. Here's a tut.
I'm not sure why supervisor would need to run at boot (logically, the only time you'd need this is while you're uploading new files), but I'd imagine it could be started at boot by just creating a new upstart config (using the same tut above for a foundation):
#!upstart
description "myapp supervisor"
author "you"
start on startup
stop on shutdown
script
echo $$ > /var/run/supervise_yourprogram.pid
// does it need root access? if so...
// exec sudo -u username supervisor --restart-on-error myapp.js
supervisor --restart-on-error myapp.js
end script
pre-stop script
rm /var/run/supervise_yourprogram.pid
end script
I'm not sure you would need monit for this case, since supervisor has its own --restart-on-error.
And here's a whole different approach, using a wrapper, which you would invoke instead of your app.js. It looks quite interesting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With