This is an example upstart script to start a node.js application.
Install the node application as sudo npm install -g github url or tarball
This file goes to /etc/init/my-node-service. To manually start the service use:
sudo service my-node-service start
To stop
sudo service my-node-service stop
To restart
sudo service my-node-service restart
The service will be automatically started on reboot.
I usually create one user for service (in this case my-node-service-user).
The stdout and stderr is redirected to /var/log/my-node-service.log
Use tail -f /var/log/my-node-service.log
to follow live logs.
Configure logrotate to rotate these logs periodically.
Another hint, I normally put my configuration in: /etc/my-node-service.json
.
This is the most standard way linux daemon works, and the paths are very standard.