Configuration and precautions of docker + supervisor + Tomcat + nginx + PHP FPM

Time:2020-10-21

Note:
1、Using docker to start, supervisor cannot run in the backgroundYou need to use / usr / bin / Supervisor – N – C / etc / Supervisor/ supervisord.conf (where – n is – nodaemon) or / usr / bin / Supervisor

[supervisord]
nodaemon=true

2、Processes managed by supervisor cannot be run by background programs。 For example, pH5 FPM cannot be started with command = / usr / SBIN / PHP5 FPM, but command = / usr / SBIN / PHP5 FPM – nodaemonize should be used

3、When supervisor manages tomcat, you need to use catalina.sh Instead of startup.sh。 The reason is that it can’t run in the background. So command = / opt / tomcat7 / bin / Catalina run
4. When supervisor manages nginx, it is necessary to configure / etc / nginx because it cannot manage background processes/ nginx.conf , in nginx.conf Top configuration ofdaemon off;

user www-data;
worker_processes auto;
pid /run/nginx.pid;

daemon off;
...

The specific configuration is as follows:

[inet_http_server]
port=localhost:9000
username=xxxx
password=111

[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

[program:chmod]
command=/bin/bash -c "chown mysql:mysql -R /opt/website/mysqldata && chown www-data:www-data -R /opt/website/www"
[program:sshd]
command=/usr/sbin/sshd -D
[program:nginx]
command=/usr/sbin/nginx
stopsignal=QUIT
[program:php-fpm]
command=/usr/sbin/php5-fpm  --nodaemonize
stopsignal=QUIT
[program:tomcat]
command=/opt/website/tomcat7/bin/catalina.sh run
startsecs=10 
stopsignal=QUIT 
user=root

The effect of supervisor management interface is as follows
Configuration and precautions of docker + supervisor + Tomcat + nginx + PHP FPM

reference resources http://stackoverflow.com/questions/32965149/supervisord-php5-fpm-exited-too-quickly
http://serverfault.com/questions/647357/running-and-monitoring-nginx-with-supervisord