Jump to content

init - file


Kjell Iver Johansen
  • Not Specified Pending Bug

Hello

Could you post an init-script for use on our server? 


User Feedback

Recommended Comments

yeah, different versions of the same distro can use different init systems. most of them use systemd now days. there are still a few hold outs on using sysV and some might still being usings ubuntu's upstart.

I'll get a guide written up for how to add one for systemd and your tech guy can get it configured and running :).

  • Like 1
Link to comment
Share on other sites

sudo nano /etc/systemd/system/babble.service

create the file, it will open, put this as the content:

[Unit]
Description=Babble Server

[Service]
ExecStart=/usr/bin/node /path/to/babble/node/folder/babble.js
Restart=always
RestartSec=5                        # Restart service after 5 seconds if node service crashes
StandardOutput=syslog               # Output to syslog
StandardError=syslog                # Output to syslog
SyslogIdentifier=babble.js-server
#User=<alternate user>
#Group=<alternate group>
Environment=NODE_ENV=production PORT=3000

[Install]
WantedBy=multi-user.target

note: if you didn't symlink nodejs to node in /usr/bin, ExecStart would be:

ExecStart=/usr/bin/nodejs /path/to/babble/node/folder/babble.js

ctrl+o (saves it), ctrl+x will exit it. (this is if you use nano, use whatever cli editor you want).

next enable:

sudo systemctl enable babble.service

start:

systemctl start babble.service

verify it:

systemctl status babble.service

this is for systemd (which i believe was adopted for ubuntu server 14.10, but it is def in 16.04 lts).

Link to comment
Share on other sites



Guest
This is now closed for further comments

×
×
  • Create New...