{"id":124,"date":"2015-09-29T11:03:03","date_gmt":"2015-09-29T11:03:03","guid":{"rendered":"https:\/\/jongarrido.es\/?p=124"},"modified":"2022-10-13T11:18:05","modified_gmt":"2022-10-13T11:18:05","slug":"nodejs-on-start","status":"publish","type":"post","link":"https:\/\/jongarrido.es\/?p=124","title":{"rendered":"nodejs on start"},"content":{"rendered":"<p>I have looked on <a href=\"http:\/\/kvz.io\/blog\/2009\/12\/15\/run-nodejs-as-a-service-on-ubuntu-karmic\/\">this post<\/a> for several and several times&#8230; I&#8217;ll repeat this procedure not to loose this useful information.<br \/>\nIt&#8217;s a simple way to run a node js server as a linux service on start. Thanks Kevin van Zonneveld.<\/p>\n<p><!--more--><\/p>\n<p>This has been tested in several distros of ubuntu&#8230; 12.04, 14.04&#8230;<\/p>\n<p>You will need to create a start script on \/etc\/init\/yourprogram.conf like this..<\/p>\n<p><code><br \/>\ndescription \"servidor para recepcion de datos gps desde tk102 y aplicaciones moviles opengts\"<br \/>\nauthor      \"Jon Garrido\"<\/code><\/p>\n<p><code># used to be: start on startup<br \/>\n# until we found some mounts weren't ready yet while booting:<br \/>\nstart on started mountall<br \/>\nstop on shutdown<\/code><\/p>\n<p><code><code><\/code><\/code><\/p>\n<p># Automatically Respawn:<br \/>\nrespawn<br \/>\nrespawn limit 99 5<\/p>\n<p><code><code><\/code><\/code><\/p>\n<p>script<br \/>\n# Not sure why $HOME is needed, but we found that it is:<br \/>\nexport HOME=\u00bb\/root\u00bb<\/p>\n<p><code><code><\/code><\/code><\/p>\n<p>exec \/usr\/local\/bin\/nodejs \/pahttoyournodeserver\/yourserver.js &gt;&gt; \/var\/log\/yourserver.log 2&gt;&amp;1<br \/>\nend script<\/p>\n<p><code><br \/>\n<\/code><\/p>\n<p><code><\/code><code>post-start script<br \/>\n# Optionally put a script here that will notifiy you node has (re)started<br \/>\n# \/root\/bin\/hoptoad.sh \"node.js has started!\"<br \/>\nend script<br \/>\n<\/code><\/p>\n<p>That&#8217;s all!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have looked on this post for several and several times&#8230; I&#8217;ll repeat this procedure not to loose this useful information. It&#8217;s a simple way to run a node js server as a linux service on start. Thanks Kevin van Zonneveld.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13,16,27],"class_list":["post-124","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-linux","tag-node-js","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=124"}],"version-history":[{"count":2,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/124\/revisions"}],"predecessor-version":[{"id":203,"href":"https:\/\/jongarrido.es\/index.php?rest_route=\/wp\/v2\/posts\/124\/revisions\/203"}],"wp:attachment":[{"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jongarrido.es\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}