I'm fairly new to all of this, so I apologize. My search has not yielded me an answer yet and I'm still testing around.
I have an Node JS app thats started by Forever on Ubuntu 12.04 LTS. Several requirements I'm trying to figure out:
- Start automatically on boot
- Being able to restart the app manually
I configured an Upstart script and it works fine, but I have no way of stopping the process correctly. I think the issue is because Upstart is looking for a PID and Forever creates a PID but doesn't tell Upstart? So when I try to stop, it doesn't know how to kill the correct process.
Here's a sample of what I'm trying to do:
#start on startup
#stop on shutdown
expect daemon
env NODE_BIN_DIR=""
env NODE_PATH=""
env APPLICATION_DIRECTORY=""
env APPLICATION_START=""
env NODE_ENV=""
#pre-start script
#sleep 15
#end script
script
PATH=$NODE_BIN_DIR:$PATH
cd /vol01/web/iin
exec sudo -u ubuntu forever -a -l $LOG -e $eLog start $APPLICATION_START
end script
pre-stop script
PATH=$NODE_BIN_DIR:$PATH
exec forever stop $APPLICATION_START
end script
I'm beginning to think the best way for me to go about this is to run a cron job on boot that would run a script to run the forever node. This script would include stopping the application and starting and I could invoke the script manually. Thoughts?