In some cases in the production environment, we faced downtime of the website, Nginx process disappeared. We want to keep the Nginx always alive without any reasons. So, we use the Supervisord as a supervisor who make sure Nginx is always alive
Add Nginx configuration on Supervisord
$ sudo vim /etc/supervisor/conf.d/nginx.conf
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
startretries=5
numprocs=1
startsecs=0
process_name=%(program_name)s_%(process_num)02d
stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
stdout_logfile_maxbytes=10MB
Let supervisord know about new config.
$ sudo supervisorctl reread
nginx: availableLet supervisord start nginx service
$ sudo supervisorctl update
nginx: added process groupVerify if supervisor started nginx service.
sudo supervisorctl
nginx:nginx_00
supervisor>Then done, you can try to stop the nginx service and you see the new Nginx's proccess always start the new one.
