diff --git a/docs/autostart_systemd.rst b/docs/autostart_systemd.rst new file mode 100644 index 000000000..774fe4b58 --- /dev/null +++ b/docs/autostart_systemd.rst @@ -0,0 +1,48 @@ +.. systemd service guide + +========================== +Setting up auto-restart using systemd on Linux +========================== + +--------------------------- +Creating the service file +--------------------------- + +Create the new service file: + +:code:`sudo nano /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 + + [Install] + WantedBy=multi-user.target + +Save and exit :code:`ctrl + O; enter; ctrl + x` + +--------------------------- +Starting and enabling the service +--------------------------- + +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` + +.. 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 **@** diff --git a/docs/index.rst b/docs/index.rst index 256dad0c2..5faf9dfc4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,6 +17,7 @@ Welcome to Red - Discord Bot's documentation! install_centos install_raspbian cog_dataconverter + autostart_systemd .. toctree:: :maxdepth: 2 diff --git a/docs/install_centos.rst b/docs/install_centos.rst index b25d6799b..265419201 100644 --- a/docs/install_centos.rst +++ b/docs/install_centos.rst @@ -4,6 +4,8 @@ Installing Red on CentOS 7 ========================== +.. warning:: For safety reasons, DO NOT install Red with a root user. Instead, `make a new one `_. + --------------------------- Installing pre-requirements --------------------------- @@ -21,19 +23,19 @@ Installing Red Without audio: -:code:`pip3 install -U --process-dependency-links red-discordbot` +:code:`pip3 install -U --process-dependency-links red-discordbot --user` With audio: -:code:`pip3 install -U --process-dependency-links red-discordbot[voice]` +:code:`pip3 install -U --process-dependency-links red-discordbot[voice] --user` To install the development version (without audio): -:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot` +:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot --user` To install the development version (with audio): -:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot[voice]` +:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot[voice] --user` ---------------------- Setting up an instance @@ -51,4 +53,4 @@ Running Red ----------- Run :code:`redbot ` and run through the initial setup. This will ask for -your token and a prefix. \ No newline at end of file +your token and a prefix. diff --git a/docs/install_debian.rst b/docs/install_debian.rst index 669e51b0f..648ebc1f3 100644 --- a/docs/install_debian.rst +++ b/docs/install_debian.rst @@ -4,7 +4,7 @@ Installing Red on Debian Stretch ================================ -.. warning:: For safety reasons, DO NOT install Red with a root user. Instead, make a new one. +.. warning:: For safety reasons, DO NOT install Red with a root user. Instead, `make a new one `_. --------------------------- Installing pre-requirements @@ -52,4 +52,4 @@ Running Red ----------- Run :code:`redbot ` and run through the initial setup. This will ask for -your token and a prefix. \ No newline at end of file +your token and a prefix. diff --git a/docs/install_raspbian.rst b/docs/install_raspbian.rst index 1453ce438..0015b4e10 100644 --- a/docs/install_raspbian.rst +++ b/docs/install_raspbian.rst @@ -4,6 +4,8 @@ Installing Red on Raspbian Stretch ================================== +.. warning:: For safety reasons, DO NOT install Red with a root user. Instead, `make a new one `_. + --------------------------- Installing pre-requirements --------------------------- @@ -19,19 +21,19 @@ Installing Red Without audio: -:code:`pip3 install -U --process-dependency-links red-discordbot` +:code:`pip3 install -U --process-dependency-links red-discordbot --user` With audio: -:code:`pip3 install -U --process-dependency-links red-discordbot[voice]` +:code:`pip3 install -U --process-dependency-links red-discordbot[voice] --user` To install the development version (without audio): -:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot` +:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot --user` To install the development version (with audio): -:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot[voice]` +:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot[voice] --user` ---------------------- Setting up an instance @@ -51,4 +53,4 @@ Running Red Run :code:`redbot ` and run through the initial setup. This will ask for your token and a prefix. -.. warning:: Audio will not work on Raspberry Pi's **below** 2B. This is a CPU problem and *cannot* be fixed. \ No newline at end of file +.. warning:: Audio will not work on Raspberry Pi's **below** 2B. This is a CPU problem and *cannot* be fixed. diff --git a/docs/install_ubuntu.rst b/docs/install_ubuntu.rst index 21a61151f..cb5eeda23 100644 --- a/docs/install_ubuntu.rst +++ b/docs/install_ubuntu.rst @@ -4,7 +4,7 @@ Installing Red on Ubuntu 16.04 ============================== -.. warning:: For safety reasons, DO NOT install Red with a root user. Instead, make a new one. +.. warning:: For safety reasons, DO NOT install Red with a root user. Instead, `make a new one `_. ------------------------------- Installing the pre-requirements @@ -21,19 +21,19 @@ Installing the bot To install without audio: -:code:`pip3 install -U --process-dependency-links red-discordbot` +:code:`pip3 install -U --process-dependency-links red-discordbot --user` To install with audio: -:code:`pip3 install -U --process-dependency-links red-discordbot[voice]` +:code:`pip3 install -U --process-dependency-links red-discordbot[voice] --user` To install the development version (without audio): -:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot` +:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot --user` To install the development version (with audio): -:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot[voice]` +:code:`pip3 install -U --process-dependency-links git+https://github.com/Cog-Creators/Red-DiscordBot@V3/develop#egg=red-discordbot[voice] --user` ------------------------ Setting up your instance @@ -51,4 +51,4 @@ Running Red ----------- Run :code:`redbot ` and run through the initial setup. This will ask for -your token and a prefix. \ No newline at end of file +your token and a prefix.