Supervisor is a program used to monitor and control programs. It can auto startup application on server boot time, and restart if the application fails.
To install supervisors on CentOS 7, first, enable epel repository.
yum install -y epel-release
Once EPEL repository is enabled, you can install supervisors with the yum command
yum install -y supervisor
Enable supervisord to start on boot, run
systemctl enable supervisord
Start supervisord
systemctl start supervisord
To start a python application on boot time, I created file
vi /etc/supervisord.d/telegram-bot.ini
With the following content
[program:telegram_bot] command=/root/bots/telegram_bot/bot.py directory=/root/bots/telegram_bot ;process_name=%(program_name)s ; process_name expr (default %(program_name)s) numprocs=1 autostart=true autorestart=true stdout_logfile=/var/log/telegram-bot.log stdout_logfile_maxbytes=1MB stdout_logfile_backups=10 stdout_capture_maxbytes=1MB stdout_events_enabled=false stderr_logfile=/var/log/telegram-bot-error.log stderr_logfile_maxbytes=1MB stderr_logfile_backups=10 stderr_capture_maxbytes=1MB stderr_events_enabled=false
Started application with
supervisorctl reload
See supervisord