I use something similar to this:
#!upstart
description "your fancy description"
author "Your Name <youremail@fqdn>"
# start on every run level, 2 is the one on Ubuntu
start on runlevel [2345]
# stop on halt, maintenance or reboot
stop on runlevel [016]
# start our application with the user `user`
exec sudo -u user -i NODE_ENV=production /path/to/bin/for/forever start /home/user/path/to/server >> /home/user/path/to/server/syslog 2>&1
# starting log
pre-start script
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /home/user/path/to/server/syslog 2>&1
end script
If you want to split the logs, define a custome PID, etc, you can use forever
's argv options to accomplish this.
If you want to have commands available to your script like stop|start|restart you can follow along with this great article: https://www.exratione.com/2013/02/nodejs-and-forever-as-a-service-simple-upstart-and-init-scripts-for-ubuntu/