To automate a script create the configuration file of your app in
sudo emacs /etc/init/app.conf
Content of the file are as follows:
# application Server description "applicationServer" author "Rahul Mehta <email@example.com" start on (net-device-up and local-filesystems and runlevel ) stop on runlevel  exec /usr/local/bin/node /your/app/path/server.js
start on, stop on and exec are the features when to start and stop your server.
we can start our server manuall by following commands :
sudo start app sudo stop app suod status app