By jongarrido | septiembre 29, 2015 | 0 Comment
I have looked on this post for several and several times… I’ll repeat this procedure not to loose this useful information.
It’s a simple way to run a node js server as a linux service on start. Thanks Kevin van Zonneveld.
This has been tested in several distros of ubuntu… 12.04, 14.04…
You will need to create a start script on /etc/init/yourprogram.conf like this..
description "servidor para recepcion de datos gps desde tk102 y aplicaciones moviles opengts"
author "Jon Garrido"
# 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
respawn limit 99 5
script
# Not sure why $HOME is needed, but we found that it is:
export HOME=»/root»
exec /usr/local/bin/nodejs /pahttoyournodeserver/yourserver.js >> /var/log/yourserver.log 2>&1
end script
post-start script
# Optionally put a script here that will notifiy you node has (re)started
# /root/bin/hoptoad.sh "node.js has started!"
end script
That’s all!!