This is a guide to use supervisorctl to keep the bot running.
Run the following command to install Supervisor:
sudo apt update
sudo apt install supervisorSupervisor configuration files are typically stored in /etc/supervisor/conf.d/. Create a new configuration file for your program, e.g., gastitis.conf:
sudo nano /etc/supervisor/conf.d/gastitis.confAdd the following content to the configuration file, replacing placeholders with your program's details:
[program:gastitis]
command=</path/to/your/venv>/bin/python manage.py startbot
directory=<path/to_your_repo>
autostart=true # Start the program when Supervisor starts
autorestart=true # Restart the program if it exits unexpectedly
stderr_logfile=/var/log/gastitis.err.log # Log for standard error
stdout_logfile=/var/log/gastitis.out.log # Log for standard output
user=<username> # The user under which to run the program
After saving the configuration file, update Supervisor to recognize the new program:
sudo supervisorctl reread
sudo supervisorctl updateStart your program using Supervisor:
sudo supervisorctl start gastitisYou can check the program's status with:
sudo supervisorctl statusTo debug or monitor the program's output, view the logs:
tail -f /var/log/gastitis.out.log
tail -f /var/log/gastitis.err.logWhen you make changes to the code, you need to pull the latest changes from your repository.
git pull origin masterThen, restart the bot:
sudo supervisorctl restart gastitisCheck the bot is running correctly:
sudo supervisorctl status