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 supervisor
Supervisor 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.conf
Add 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 update
Start your program using Supervisor:
sudo supervisorctl start gastitis
You can check the program's status with:
sudo supervisorctl status
To debug or monitor the program's output, view the logs:
tail -f /var/log/gastitis.out.log
tail -f /var/log/gastitis.err.log