Configuring Ambience/Repertoire 2020+ as Linux Service

The following entry below guides you through the steps to run the Ambience/Repertore 202x as a Linux service using systemd.

Prerequisites:

  • Ensure that Java is installed before carrying out the steps stated below.
  • For Ambience 202x, do ensure that the MongoDB service will get respawned and auto-restarts in case of a crash.
    (Reference Link: How to Auto-Restart MongoDB Service)
  • This entry applies to both Ambience 202x and Repertoire 202x.

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

  2. Unzip the Ambience/Repertoire distribution into a folder.
    For example, “/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

**For Repertoire, do revise the mappings as accordingly.

  1. 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*

**For Repertoire, do revise the mappings as accordingly.

  1. Download a copy of the service file and attached it into /etc/systemd/system.
    For Ambience 202x: ambience_service.zip
    For Repertoire 202x: repertoire_service.zip

Example of .service file content


#!/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:
    For Ambience 202x: sudo systemctl start ambience
    For Repertoire 202x: sudo systemctl start repertoire

  • 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:
    For Ambience 202x: sudo systemctl status ambience
    For Repertoire 202x: sudo systemctl status repertoire

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

  3. Input the following to get systemd to start the service every time the server restarts:
    For Ambience 202x: sudo systemctl enable ambience
    For Repertoire 202x: sudo systemctl enable repertoire