Skip to content

Deployment as Linux service

Jakob Voß edited this page Jan 2, 2018 · 3 revisions

''A LDF server can be set up this way at Ubuntu 16.04 LTS. Some choices are opiniated.''

First create a user account, home directory, and config directory:

$ sudo adduser --disabled-password --home /srv/ldf ldf
$ sudo mkdir /etc/ldf
$ sudo chown ldf:ldf /etc/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 sand link it from the installation directory:

$ vim /etc/ldf/config.json
$ ln -s /etc/ldf/config.json config.json

Local files should better be referred to by absolute path. 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 /etc/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

Configuration of logging with systemctl requires https://github.com/LinkedDataFragments/Server.js/pull/70

Clone this wiki locally