La idea de iniciar sus servicios bajo la supervisión de Supervisor es poder ejecutar múltiples servicios bajo un solo demonio. Dependiendo de la configuración del Supervisor, podrá iniciar, detener o reiniciar cualquier servicio dado como un proceso secundario. En esta configuración mostramos cómo ejecutar apache2
como servicio supervisado (útil para imágenes docker, etc.) en Ubuntu/Debian Linux.
Primero, instale supervisor:
# apt-get install supervisor
Incluir apache2
configuración del supervisor en /etc/supervisor/conf.d/
. Supervisor elegirá cualquier archivo de configuración de este directorio donde el único requisito es *.conf
extensión de archivo. Por ejemplo, inserte las siguientes líneas en un nuevo archivo /etc/supervisor/conf.d/apache2.conf
:
[program:apache2] command=/usr/sbin/apache2ctl -DFOREGROUND
Una vez que haya incluido el archivo de configuración anterior, detenga el servidor web apache2 si se está ejecutando actualmente:
# /etc/init.d/apache2 stop [ ok ] Stopping web server: apache2. root@4e004b451a98:/# /etc/init.d/apache2 status [FAIL] apache2 is not running ... failed!
y reiniciar supervisor:
# /etc/init.d/supervisor restart Restarting supervisor: supervisord.
Una vez que haya reiniciado el supervisor, también se debe iniciar el servidor web apache2. Confirme que el servidor web apache2 se está ejecutando:
# /etc/init.d/apache2 status [ ok ] apache2 is running.
Resolución de problemas
si por alguna razón no puede hacer que apache se ejecute bajo el supervisor, ejecute el supervisor en nodaemon
modo:
# /etc/init.d/supervisor stop Stopping supervisor: supervisord. # supervisord -n
Mensaje de error:
/usr/lib/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security. 'Supervisord is running as root and it is searching ' 2015-05-07 01:21:00,849 CRIT Supervisor running as root (no user in config file) 2015-05-07 01:21:00,849 WARN Included extra file "/etc/supervisor/conf.d/apache2.conf" during parsing 2015-05-07 01:21:00,858 INFO RPC interface 'supervisor' initialized 2015-05-07 01:21:00,858 CRIT Server 'unix_http_server' running without any HTTP authentication checking 2015-05-07 01:21:00,858 INFO supervisord started with pid 542 2015-05-07 01:21:01,862 INFO spawned: 'apache2' with pid 545 2015-05-07 01:21:01,914 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:02,918 INFO spawned: 'apache2' with pid 548 2015-05-07 01:21:02,970 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:04,975 INFO spawned: 'apache2' with pid 551 2015-05-07 01:21:05,025 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:08,031 INFO spawned: 'apache2' with pid 554 2015-05-07 01:21:08,078 INFO exited: apache2 (exit status 0; not expected) 2015-05-07 01:21:09,079 INFO gave up: apache2 entered FATAL state, too many start retries too quickly
Si ve el mensaje de error anterior, asegúrese de que su servidor web Apache no se esté ejecutando ya.
Otro mensaje de error que puede ver es:
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf: Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
Esto se debe a que está intentando ejecutar apache2
manda directamente. Puede intentar ejecutar apache2ctl
en su lugar.