{"id":6426,"date":"2020-05-15T09:48:53","date_gmt":"2020-05-15T14:48:53","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=6426"},"modified":"2020-05-15T09:48:53","modified_gmt":"2020-05-15T14:48:53","slug":"nodejs-unit-file","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=6426","title":{"rendered":"NodeJS Unit File"},"content":{"rendered":"\n<p>For future reference, this is an example unit file for running a NodeJS server with systemd. The NodeJS code we use reads from a local MariaDB, so I&#8217;ve added a service dependency for the database server. <\/p>\n\n\n\n<p>Create \/etc\/systemd\/system\/nodeserver.service<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n&#x5B;Unit]\nDescription=SiteName Node.js Server\nRequires=After=mariadb.service\n\n&#x5B;Service]\nExecStart=\/path\/to\/binary\/for\/node \/path\/to\/nodeJS\/html\/server.js\nWorkingDirectory=\/path\/to\/nodeJS\/html\nRestart=always\nRestartSec=30\nStandardOutput=syslog\nStandardError=syslog\nSyslogIdentifier=nodejs-sitename\nUser=web-user\nGroup=www-group\n\n&#x5B;Install]\nWantedBy=multi-user.target\n<\/pre><\/div>\n\n\n<p>Use systemctl daemon-reload to register the new unit file, then &#8220;systemctl start nodeserver.service&#8221; to start the service. Assuming everything works properly, use &#8220;systemctl enable nodeserver.service&#8221; to have the service start on boot. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>For future reference, this is an example unit file for running a NodeJS server with systemd. The NodeJS code we use reads from a local MariaDB, so I&#8217;ve added a service dependency for the database server. Create \/etc\/systemd\/system\/nodeserver.service Use systemctl daemon-reload to register the new unit file, then &#8220;systemctl start nodeserver.service&#8221; to start the service. &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,30],"tags":[974,975,586,976],"class_list":["post-6426","post","type-post","status-publish","format-standard","hentry","category-coding","category-system-administration","tag-node","tag-nodejs","tag-systemd","tag-unit-file"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6426"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6426\/revisions"}],"predecessor-version":[{"id":6427,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/6426\/revisions\/6427"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}