Red-DiscordBot/docs/autostart_systemd.rst
Toby Harradine ce031cf7bd
[Docs] Add virtualenv guide and compress install guides (#2029)
* [Docs] Add virtualenv guide and compress install guides

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* [Docs] Better cross-referencing

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Fix pyenv-installer link

Signed-off-by: Toby Harradine <tobyharradine@gmail.com>

* Use sudo -e instead of sudo nano

* Add note about launcher for linux/mac

* Include launcher notes in Windows guide

* Add missing colon
2018-08-26 23:44:56 +10:00

54 lines
1.5 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. systemd service guide
==============================================
Setting up auto-restart using systemd on Linux
==============================================
-------------------------
Creating the service file
-------------------------
Create the new service file:
:code:`sudo -e /etc/systemd/system/red@.service`
Paste the following and replace all instances of :code:`username` with the username your bot is running under (hopefully not root):
.. code-block:: none
[Unit]
Description=%I redbot
After=multi-user.target
[Service]
ExecStart=/home/username/.local/bin/redbot %I --no-prompt
User=username
Group=username
Type=idle
Restart=always
RestartSec=15
RestartPreventExitStatus=0
[Install]
WantedBy=multi-user.target
Save and exit :code:`ctrl + O; enter; ctrl + x`
---------------------------------
Starting and enabling the service
---------------------------------
.. note:: This same file can be used to start as many instances of the bot as you wish, without creating more service files, just start and enable more services and add any bot instance name after the **@**
To start the bot, run the service and add the instance name after the **@**:
:code:`sudo systemctl start red@instancename`
To set the bot to start on boot, you must enable the service, again adding the instance name after the **@**:
:code:`sudo systemctl enable red@instancename`
To view Reds log, you can acccess through journalctl:
:code:`sudo journalctl -u red@instancename`