-
Notifications
You must be signed in to change notification settings - Fork 60
Deployment as Linux service
A LDF server can be set up this way at Ubuntu 16.04 LTS. Some choices are opiniated.
First create a user account and home directory (I prefer to run services as distinct user, this is not required).
$ sudo adduser --disabled-password --home /srv/ldf ldf
Then login as the new user and install Server.js in its home directory /srv/ldf/
$ sudo -u ldf bash
$ cd /srv/ldf
$ git init
$ git remote add origin https://github.com/LinkedDataFragments/Server.js.git
$ git pull origin master
Then install dependencies:
$ HOME=/srv/ldf npm install
Then create a config file /srv/ldf/config.json
. Configuration may also be placed at another location, e.g. /etc/ldf/config.json
to separate executables and configuration.
The server can then be tested:
$ ./bin/ldf-server config.json
If the server works fine, kill it and log out to make it permament by creating file /lib/systemd/system/ldf.service
as root:
$ exit
$ sudo vim /lib/systemd/system/ldf.service
The contents of this file:
[Unit]
Description=LDF - Linked Data Fragments Server
After=network.target
[Service]
Type=simple
User=ldf
ExecStart=/usr/bin/node /srv/ldf/bin/ldf-server /srv/ldf/config.json
Restart=on-failure
[Install]
WantedBy=multi-user.target
Then reload systemd configuration and start the service for testing:
$ sudo systemctl daemon-reload
$ sudo systemctl start ldf
$ sudo systemctl status ldf
If everything works fine, enable the service to be started after booting:
$ sudo systemctl enable ldf
I have not configured logging, this should go to /var/log/ldf/
. For README.md
the contents of /lib/systemd/system/ldf.service
may be enough documentation.