Skip to content

Instantly share code, notes, and snippets.

@Morgyn
Last active April 22, 2021 16:11
Show Gist options
  • Select an option

  • Save Morgyn/746993066640d1449d7780b8f63b7fb0 to your computer and use it in GitHub Desktop.

Select an option

Save Morgyn/746993066640d1449d7780b8f63b7fb0 to your computer and use it in GitHub Desktop.
systemd service file for Auto Voice Channels discord bot.

systemd service file for Auto Voice Channels discord bot.

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 AVCtest or: service AVCtest start
  • start, restart or stop are 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment