itabashi icon indicating copy to clipboard operation
itabashi copied to clipboard

Create systemd Service

Open antonizoon opened this issue 8 years ago • 2 comments

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

antonizoon avatar Mar 07 '16 21:03 antonizoon

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/

antonizoon avatar May 19 '16 04:05 antonizoon

I wonder whether the process actually exits in those cases where it fails... anyway, we'll see how this goes in that case.

DanielOaks avatar May 19 '16 05:05 DanielOaks