Skip to content

Latest commit

 

History

History
81 lines (60 loc) · 1.92 KB

File metadata and controls

81 lines (60 loc) · 1.92 KB

Keep bot runnin in server

This is a guide to use supervisorctl to keep the bot running.

1. Install supervisorctl

Run the following command to install Supervisor:

sudo apt update
sudo apt install supervisor

2. Create a Configuration File for Your Program

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

3. Add Configuration for Your Program

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

4. Update Supervisor Configuration

After saving the configuration file, update Supervisor to recognize the new program:

sudo supervisorctl reread
sudo supervisorctl update

5. Start and Monitor Your Program

Start your program using Supervisor:

sudo supervisorctl start gastitis

You can check the program's status with:

sudo supervisorctl status

6. View Logs

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

7. Deploy new changes

When you make changes to the code, you need to pull the latest changes from your repository.

git pull origin master

Then, restart the bot:

sudo supervisorctl restart gastitis

Check the bot is running correctly:

sudo supervisorctl status