注意點:
一、使用docker啓動,supervisor不能在後臺運行
,須要使用/usr/bin/supervisord -n -c/etc/supervisor/supervisord.conf(其中-n爲–nodaemon)或者/usr/bin/supervisord並配置php
[supervisord] nodaemon=true
二、supervisor管理的進程不能之後臺程序運行
。好比ph5-fpm啓動不能command=/usr/sbin/php5-fpm,而應該使用command=/usr/sbin/php5-fpm –nodaemonize mysql
三、supervisor管理tomcat時,須要使用catalina.sh而非startup.sh
。緣由就是不能以非後臺運行。因此command=/opt/tomcat7/bin/catalina run
四、supervisor管理nginx時,因爲不能管理後臺進程,因此須要配置/etc/nginx/nginx.conf,在nginx.conf的頂端配置daemon off
;nginx
user www-data; worker_processes auto; pid /run/nginx.pid; daemon off; ...
具體配置以下:web
[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
supervisor管理界面效果以下sql
參考http://stackoverflow.com/questions/32965149/supervisord-php5-fpm-exited-too-quickly
http://serverfault.com/questions/647357/running-and-monitoring-nginx-with-supervisorddocker