Configuring Ambience 2020+ as Linux Service

The following entry below guides you through the steps to run the Ambience 2020+ as a Linux service using systemd.

Prerequisites:

  • Ensure that Java is installed before carrying out the steps stated below.
  • Ensure that the MongoDB service will get respawned and auto-restarts in case of a crash.
    (Reference Link: How to Auto-Restart MongoDB Service)

  1. Create a new user to run the service, e.g. elixir:
    For example → sudo adduser elixir

  2. Unzip the Ambience distribution into a folder, e.g. “/opt/ElixirAmbience202x”. Do ensure that the owner is set to the user created in Step 1 (i.e. “elixir”).
    For example → sudo chown +R elixir:elixir /opt/ElixirAmbience202x

  3. Make the shell scripts executable, or adjust permissions as needed to minimize access to the created user (i.e. “elixir”).
    For example → sudo chmod +x /opt/ElixirAmbience/bin/.sh*

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

Contents of the file looks like this:


#!/bin/sh -

[Unit]
Description=Elixir Ambience 202x Service

[Service]
User=elixir Do revise the user name as needed.
WorkingDirectory=/opt/ElixirAmbience202x/bin Do revise the path as needed.
ExecStart=/opt/ElixirAmbience202x/bin/run-server Do revise the path as needed.
Restart=on-failure

[Install]
WantedBy=multi-user.target


  • Do ensure that the user is set to the created user (i.e. “elixir”) and the chosen install location is set in both “WorkingDirectory” and “ExecStart” (relative paths are not allowed in either of these)
  1. Use systemd to load new service:
    sudo systemctl daemon-reload

  2. Use the command below to start the service explicitly:
    sudo systemctl start ambience

  • do note that the running.lock, data folder and log folder are all created by the created user (i.e. “elixir”), showing the correct account is used.
  1. The last set of console line can be seen using the following command:
    sudo systemctl status ambience

  2. Use the command below to stop the service (wait 10 secs and the running.lock should be removed):
    sudo systemctl stop ambience

  3. Input the following to get systemd to start the service every time the server restarts:
    sudo systemctl enable ambience