install forever to run nodejs as service. logs in a hidden .forever directory in the home directory of the user you ran forever as. Startup: All you need to do is create a file named something like myapp.conf in /etc/init with the following contents:
start on startup exec forever start /full/path/to/test.js
sudo npm -g install forever
export PATH=$PATH:/usr/local/bin
export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules
ln -s /usr/bin/nodejs /usr/bin/node
forever start test.js