Skip to content

Run RemoteRotator as a Linux Service

Tobias Wellnitz edited this page Feb 8, 2019 · 2 revisions

Most of the time we want to run remoteRotator as a background service. This tutorial explains how to run remoteRotator instances as services managed by systemd. Doing so is handy, because systemd will take care of launching remoteRotator on system startup or relaunching it in case the software crashes. This tutorial has been written for Ubuntu 16.04 and might require some minor adaptations if you run on a different OS (Debian, Centos...).

Create a user for our service

It is good practice to run services with as little rights as possible. We therefore create a dedicated user named rotator:

sudo adduser --system --group --no-create-home --shell /bin/false rotator

Now we add our user rotator to the group dialout so that it can open our serial port devices located in /dev:

sudo addgroup rotator dialout

Create the service definition

Systemd service definitions are typically stored in either /etc/systemd/system. So we create the file tower1.service for our first rotator, located on tower #1:

sudo nano /etc/systemd/system/tower1.service

and paste:

[Unit]
Description=RemoteRotator Tower1
After=network.target
StartLimitInterval=0 # try endless
StartLimitBurst=1 # limit trying restart to once (within the RestartSec period)

[Service]
User=rotator
ExecStart=/usr/local/bin/remoteRotator server lan -d /dev/tower1 --azimuth-stop 180 -n "Tower1" -w "0.0.0.0" -k 7071
Restart=always
RestartSec=5 # try to restart every 5 seconds if not running

[Install]
WantedBy=multi-user.target%

In order to be sure that the file does not contain any syntax errors we can check it with the following command:

sudo systemd-analyze verify tower1.service

Now we can enable the service so that it starts automatically after boot:

sudo systemctl enable tower1.service

and start the service:

sudo systemctl start tower1.service

in order to check if the service has started properly, check:

systemctl status tower1.service

which should output something like this:

● tower1.service - RemoteRotator Tower1
   Loaded: loaded (/etc/systemd/system/tower1.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-10-09 00:18:02 CEST; 24min ago
 Main PID: 865 (remoteRotator)
   CGroup: /system.slice/tower1.service
           └─865 /usr/local/bin/remoteRotator server lan -d /dev/tower1 --azimuth-stop 180 -n Tower1 -w 0.0.0.0 -k 7071

Oct 09 00:18:02 aurora systemd[1]: Started RemoteRotator Tower1.
Oct 09 00:18:08 aurora remoteRotator[865]: no config file found

Repeat

Now you can create services for your other rotators or the remoteRotator web. You just have to adopt the command in the systemd service definition.

Clone this wiki locally