[FAQ]: Configuring Ambience Server as Linux Service

The following steps below was carried out using systemd. These steps below assume that Java is already installed and available on the system path.

1/Create a new user to run the service, e.g. elixir:

sudo adduser elixir

2/Unzip the Ambience distribution into a folder, e.g. /opt/ElixirAmbience, and set the owner to elixir:

sudo chown +R elixir:elixir /opt/ElixirAmbience

3/Make the shell scripts executable, or adjust permissions as needed to minimise access to the elixir user:

sudo chmod +x /opt/ElixirAmbience/bin/.sh*

4/Download and copy the attached ambience_service.zip (323 Bytes) file into /etc/systemd/system.

The contents of the file looks like this:


#!/bin/sh -

[Unit]

Description=Elixir Ambience Service

[Service]

User=elixir

WorkingDirectory=/opt/ElixirAmbience/bin

ExecStart=/opt/ElixirAmbience/bin/run-server.sh

Restart=on-failure

[Install]

WantedBy=multi-user.target


Note the user is set to elixir and the chosen install location is set in both WorkingDirectory and ExecStart (relative paths are not allowed in either of these)

5/Use systemd to load new service:

sudo systemctl daemon-reload

6/Service can be started explicitly:

sudo systemctl start ambience

Note that the running.lock, data folder and log folder are all created by the elixir user, showing the correct account is used.

7/The last set of console lines with can be seen using:

sudo systemctl status ambience

which also includes a useful process tree:

Main PID: 28279 (run-server.sh)

CGroup: /system.slice/ambience.service

       ├─28279 /bin/sh /opt/ElixirAmbience/bin/run-server.sh

       ├─28280 java -[Dvisualvm.display.name](http://dvisualvm.display.name/)=AmbienceServer -Delixir.home=. -Djetty.home=jetty -Djetty.base=jetty/elx-base

       ├─28367 java -Delixir.domain=eno -Djobengine.name=first -Djava.awt.headless=true -Dlogback.configurationFile=etc/j

       └─28371 java -Delixir.domain=eno -Djobengine.name=second -Djava.awt.headless=true -Dlogback.configurationFile=etc/

8/Stop the service using (wait 10 secs and the running.lock should be removed):

sudo systemctl stop ambience

9/Input the following to get systemd to start the service every time the server restarts:

sudo systemctl enable ambience