Skip to content

Instantly share code, notes, and snippets.

@Yandols
Last active July 23, 2016 07:50
Show Gist options
  • Save Yandols/13c3a4343203527091161c66b70cc893 to your computer and use it in GitHub Desktop.
Save Yandols/13c3a4343203527091161c66b70cc893 to your computer and use it in GitHub Desktop.
Autorestarting on Fedora / systemd
How to make Red auto restart in case of crash, using systemd. This guide assumes you used the Fedora guide to install Red.
Run this command in terminal:
sudo nano /etc/systemd/system/multi-user.target.wants/red.service
Next, paste the following script (not including the lines), replace all instances of "username" with your fedora account name and "usergroup" with your user’s group (usually the same as the username, but you can check with 'groups username' in the terminal.)
-----------------------------------------------------------
[Unit]
Description=Red-DiscordBot Background Service
Documentation="https://twentysix26.github.io/Red-Docs/"
After=multi-user.target
[Service]
Type=idle
User=username
Group=usergroup
WorkingDirectory=/home/username/Red-DiscordBot/
ExecStart=/usr/bin/python3.5 /home/username/Red-DiscordBot/red.py --no-prompt
ExecReload=/usr/bin/python3.5 /home/username/Red-DiscordBot/red.py --no-prompt
# If set to "on-failure" Red will only restart when it crashed or froze, but not when [p]shutdown is used. (froze untested)
# If set to "always" Red will always attempt to restart regardless of how it was turned off.
Restart=on-failure
# Limit waiting for Red to stop to 60 seconds to prevent terminal from freezing up.
# If time is up, Red will be terminated forcibly via SIGTERM instead of the default SIGINT.
TimeoutStopSec="60s"
# Send SIGINT for graceful stop
KillSignal=SIGINT
KillMode=mixed
[Install]
WantedBy=multi-user.target
-----------------------------------------------------------
Save with CTRL+O.
Next, you need to give the permissions to the newly created service by using
sudo chmod 644 /etc/systemd/system/multi-user.target.wants/red.service
Now you need to reload the systemd configuration by using
sudo systemctl daemon-reload
You can now start Red using
sudo systemctl start red
Other available commands:
sudo systemctl status red
sudo systemctl restart red
sudo systemctl stop red
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment