Pregunta Ejecutando (y monitoreando) nginx con supervisord


Comenzaré con mi caso de uso, ya que es muy posible que no esté utilizando las herramientas correctas para este trabajo. Por favor, hágamelo saber si estoy haciendo esto de forma incorrecta.

caso de uso: tengo un servidor CentOS que aloja múltiples aplicaciones web. Quiero poder confiar en que mi servidor web y mi servidor de aplicaciones se ejecutarán. Mi pila parece

  • servidor web: nginx
  • servidor de aplicaciones: uWSGI
  • marco web: matraz / pitón

Quiero usar supervisord para monitorear nginx y uWSGI. En mi /etc/supervisor.conf, tengo

[program:nginxgo]
command = /usr/sbin/nginx
autostart=true
autorestart=unexpected
exitcodes=0
stdout_logfile=/home/webdev/nginxgo.log
stderr_logfile=/home/webdev/nginxgoerr.log

[program:uwsgi_emperor_go]
command = uwsgi --emperor /etc/uwsgi/emperor.ini
autostart=true
autorestart=unexpected
stopsignal=INT
stdout_logfile=/home/webdev/emp.log
stderr_logfile=/home/webdev/emperr.log
directory=/home/webdev/
user=webdev

Tengo el proceso uWSGI para comenzar. Cuando entro [root@mymachine]# /usr/local/bin/supervisord -n -c /etc/supervisord.conf

la salida es

2014-11-26 14:07:56,917 CRIT Supervisor running as root (no user in config file)
2014-11-26 14:07:56,951 CRIT Server 'inet_http_server' running without any HTTP authentication checking
2014-11-26 14:07:56,952 INFO supervisord started with pid 31068
2014-11-26 14:07:57,957 INFO spawned: 'nginxgo' with pid 31071
2014-11-26 14:07:57,970 INFO spawned: 'uwsgi_emperor_go' with pid 31072
2014-11-26 14:07:59,095 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:07:59,095 INFO success: uwsgi_emperor_go entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:00,601 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:01,607 INFO spawned: 'nginxgo' with pid 31079
2014-11-26 14:08:02,684 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:04,189 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:05,194 INFO spawned: 'nginxgo' with pid 31080
2014-11-26 14:08:06,264 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:07,771 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:08,775 INFO spawned: 'nginxgo' with pid 31081
2014-11-26 14:08:09,808 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:11,314 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:12,319 INFO spawned: 'nginxgo' with pid 31082
2014-11-26 14:08:13,381 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:14,886 INFO exited: nginxgo (exit status 1; not expected)
^C2014-11-26 14:08:15,601 INFO spawned: 'nginxgo' with pid 31083
2014-11-26 14:08:15,603 WARN received SIGINT indicating exit request
2014-11-26 14:08:15,611 INFO waiting for nginxgo, uwsgi_emperor_go to die
2014-11-26 14:08:16,738 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:08:18,242 INFO exited: nginxgo (exit status 1; not expected)
2014-11-26 14:08:19,244 INFO waiting for uwsgi_emperor_go to die
2014-11-26 14:08:21,607 INFO stopped: uwsgi_emperor_go (exit status 0)

Mira como dice

2014-11-26 14:07:59,095 INFO success: nginxgo entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-26 14:07:59,095 INFO success: uwsgi_emperor_go entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

pero luego comienza simplemente ciclando el proceso nginxgo. Maté la instancia de supervisor con CTRL-C, y veo en htop que el nginx master process y worker process ambos están activos.

Todo lo que quiero es empezar. nginx y mi uWSGI emperor en el arranque / reinicio del servidor o falla de cualquiera de los programas


5
2017-11-26 19:17


origen




Respuestas:


Supervord solo puede manejar procesos en primer plano. El valor predeterminado para nginx se ejecuta en segundo plano como demonio.

Para asegurarse de que su nginx se está ejecutando con supervisord, debe configurar 'daemon off' en su nginx.conf (vea también nginx docu en http://nginx.org/en/docs/ngx_core_module.html#daemon).


8
2017-11-26 20:53



En la configuración de nginx, ingrese daemon off entonces funciona con supervisor - Brian Leach
Hace el stop ¿Trabajo de acción cuando usas esta técnica? start trabajó para mí después de que agregué sudo en el supervisor command atributo. Intenté correr supervisorctl stop nginx y se quejó con OSError. - Olivier Cervello