i'm try to run nodejs as service as this steps
sudo vim servicelocator.conf
past this .conf
description "node.js server"
author "mahmoud elgohary"
# Used to Be: Start on Startup
# until we found some mounts weren't ready yet while booting:
start on started mountall
stop on shutdown
# Automatically Respawn:
respawn limit 99 5
# Not sure why $HOME is needed, but we found that it is:
exec /usr/bin/node /var/lib/nodejsproject/servicelocator/server.js >> /var/log/node.log 2>&1
# Optionally put a script here that will notifiy you node has (re)started
# /root/bin/hoptoad.sh "node.js has started!"
ubuntu@ip-172-31-37-243:/etc/init$ sudo start servicelocator
start: Unknown job: servicelocator
I did this with upstart:
sudo apt-get install upstart
sudo vim /etc/init/servicelocator.conf
servicelocator.confthat you created and insert the text below:
#!upstart description "servicelocator"
start on runlevel  stop on runlevel 
#Automatically Respawn: respawn respawn limit 99 5
exec /usr/bin/node /var/lib/nodejsproject/servicelocator/server.js >> /var/log/node.log
Save and close the file.
To start the service:
sudo start servicelocator