mirror of
https://github.com/Mikaela/Limnoria-doc.git
synced 2024-11-26 22:39:25 +01:00
Merge pull request #73 from Mikaela/systemd
use: make supybot-botchk more general purpouse
This commit is contained in:
commit
86c3f70136
@ -1,18 +1,26 @@
|
||||
.. _supybot-botchk:
|
||||
|
||||
##############
|
||||
################################
|
||||
Restarting the bot automatically
|
||||
################################
|
||||
|
||||
This page documents the different ways to automatically restart your bot
|
||||
in case of crash or system reboot or anything that can make the bot quit.
|
||||
|
||||
Note that you only need to use one.
|
||||
|
||||
supybot-botchk
|
||||
##############
|
||||
==============
|
||||
|
||||
supybot-botchk is a script that comes with Supybot which restarts the bot
|
||||
if it quits or system reboots or anything that causes the bot to quit. It's
|
||||
placed to crontab so cron will run it with scheduled intervals.
|
||||
|
||||
How to use it?
|
||||
==============
|
||||
--------------
|
||||
|
||||
Configuring the bot
|
||||
-------------------
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Start by telling your bot to write a pidfile somewhere where it can write
|
||||
and restart the bot. For example::
|
||||
@ -23,7 +31,7 @@ where <username> is replaced with the system username and <bot> is replaced
|
||||
with the name of the bot.
|
||||
|
||||
crontab
|
||||
-------
|
||||
^^^^^^^
|
||||
|
||||
After the pidfile is configured, you can modify crontab. First you should
|
||||
copy the output of::
|
||||
@ -71,3 +79,44 @@ If you are wondering what ``*/5 * * * *`` means, it simply means "run this
|
||||
every five minutes every day". The 5 can be replaced with any other number
|
||||
and there are also ``@hourly`` etc. which can be used on it's place, but
|
||||
you most likely won't want to wait hour or more if your bot crashes.
|
||||
|
||||
systemd service
|
||||
===============
|
||||
|
||||
You need root access as no one has got this to work as user service yet.
|
||||
You must also use systemd as your init.
|
||||
|
||||
Create a new file ``/etc/systemd/system/<BOTNAME>.service`` with the
|
||||
following content replacing things were suitable::
|
||||
|
||||
[Unit]
|
||||
Description=Supybot
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Environment="PATH=/usr/local/bin:/usr/local/sbin:/usr/local/games:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/bin:/opt/local/bin:/opt/local/sbin:/opt/local/games TZ=UTC"
|
||||
Type=forking
|
||||
ExecStart=/usr/local/bin/supybot /home/bot/botname/botname.conf --daemon
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Restart=always
|
||||
User=BOTUSERNAME
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
Now you should run ``systemctl daemon-reload`` to make systemd aware
|
||||
of changed files and ``systemctl enable <BOTNAME>.service`` to make the
|
||||
bot start on boot etc. and ``systemctl start <BOTNAME>.service`` to start
|
||||
the bot.
|
||||
|
||||
Remember to check the ``Ènvironment`` line. You can get your PATH with
|
||||
``printf 'PATH=%s\n' "$PATH"``.
|
||||
|
||||
Some commands
|
||||
-------------
|
||||
|
||||
* autostart on boot: ``systemctl enable <BOTNAME>.service``
|
||||
* disable autostart on boot: ``systemctl disable <BOTNAME>.service``
|
||||
* start the bot: ``systemctl start <BOTNAME>.service``
|
||||
* stop the bot: ``systemctl stop <BOTNAME>.service``
|
||||
* reload config files: ``systemctl reload <BOTNAME>.service``
|
||||
|
Loading…
Reference in New Issue
Block a user