itabashi
itabashi copied to clipboard
Create systemd Service
I've created an impromptu systemd service for itabashi to use:
It requires the user itabashi
to be created on the system, with this git repo cloned into /home/itabashi/itabashi
. Then it runs the the bot under the virtualenv using service.sh
:
However, it's not altogether elegant. Maybe there could be an installation script and such. But either way it works for now.
/etc/systemd/system/itabashi.service
[Unit]
Description=Itabashi Discord/IRC Bridge
After=multi-user.target
[Service]
ExecStart=/home/itabashi/itabashi/service.sh
WorkingDirectory=/home/itabashi/itabashi/
User=itabashi
Group=itabashi
[Install]
WantedBy=multi-user.target
/home/itabashi/itabashi/service.sh
source env/bin/activate
python3 startlink.py connect
Sometimes itabashi will just fail inexplicably every few days, for some unknown reason relating to async.io and Discord.py. Restarting the service will work fine, and eventually it meets this problem.
For now, we will just tell Systemd to immediately restart the service upon any failure. it's not perfect but Itabashi works fine nevertheless.
https://jonarcher.info/2015/08/ensure-systemd-services-restart-on-failure/
I wonder whether the process actually exits in those cases where it fails... anyway, we'll see how this goes in that case.