This example was developed for and tested on Debian 10.4, the below describes how to configure systemd to run a single instance of the bot.
For this example we are using a service called AVCtest, the systemd file will be named AVCtest.service.
It will run under a user avctest and the installation was performed in the home directory of that user. (/home/avctest)
Instructions:
- Install service file (
AVCtest.service) in/etc/systemd/system - load the service into systemd, this has to be performed with any change to the service file:
systemctl daemon-reload - Enable the service on system startup:
systemctl enable AVCtest.service - Start the service with either:
systemctl start AVCtestor:service AVCtest start start,restartorstopare available parameters that work as they state.
AVCtest.service:
[Unit]
Description=AVCTest
After=syslog.target network.target
[Service]
Type=simple
User=avctest
WorkingDirectory=/home/avctest/Auto-Voice-Channels
ExecStart=/home/avctest/Auto-Voice-Channels/bot-env/bin/python /home/avctest/Auto-Voice-Channels/auto-voice-channels.py
Restart=always
[Install]
WantedBy=multi-user.target
If you had multiple bots you could use templating, renaming the file to AVC@.service and replacing the variances in the settings with %i. For example you could issue a service AVC@avctest start and replace every instance of avctest in the above with %i, this however is risky and requires some thought to make secure.