How host a python bot / Comment héberger un bot python



J’aimerai héberger un bot Discord, python donc, sur mon serveur. Est-ce qu’il existe une app pour faire exécuter une app python en continu ? Je ne me charge nullement du développement du bot, juste de l’héberger, si c’est possible.

I want to host a Discord (Python) bot on my server. Is there an application to continuously run a python app?
I didn’t develop the bot, I just want to host it, if possible.


No, there is no such app at the moment. Good thing YunoHost is not the jealous type, you can install that kind of script on your own without it interfering with the server.

What I advise you to do:

  1. create a dedicated user and its directory for the script: sudo useradd -d /opt/bot_discord -m
  2. use sudo nano /opt/bot_discord/ or whatever to put your script in the directory. The first line should be #!/usr/bin/env python3 or something equivalent for the system to know which version of python to use.
  3. sudo chmod 550 /opt/bot_discord/ and sudo chown bot_discord:bot_discord -R /opt/bot_discord to secure the file
  4. create a service file with sudo nano /etc/systemd/system/bot_discord.service. Example taken from our good old YunoMDNS service:
Description=Discord bot



(PYTHONUNBUFFERED=1 is required to make the script verbose while it runs, helpful for debugging)

  1. Refresh the daemon list with sudo systemctl daemon-reload
  2. You can even integrate it in your YunoHost panel: sudo yunohost service add bot_discord
  3. Start it from the webadmin and hope for the best :crossed_fingers:
1 Like

Thank you for this detailled protocol! It seems doable with my little tech-background.
I will try it in the next few days.