Supervisor 介绍
Supervisord是用Python实现的一款非常实用的进程管理工具,类似于monit,monit和supervisord的一个比较大的差异是supervisord管理的进程必须由supervisord来启动,monit可以管理已经在运行的程序;supervisord还要求管理的程序是非daemon程序,supervisord会帮你把它转成daemon程序,因此如果用supervisord来管理nginx的话,必须在nginx的配置文件里添加一行设置daemon off让nginx以非daemon方式启动。
官方文档:http://supervisord.org/index.html文章源自运维生存时间-https://www.ttlsa.com/linux/supervisor-linux-process-control-management/
安装Setuptools
wget -c http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e tar zxvf setuptools-0.6c11.tar.gz cd setuptools-0.6c11 python setup.py install
安装Supervisor
easy_install supervisor
supervisor 配置
以gearman worker为例:文章源自运维生存时间-https://www.ttlsa.com/linux/supervisor-linux-process-control-management/
[unix_http_server] file=/tmp/supervisor.sock ; (the path to the socket file) [supervisord] logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) logfile_backups=10 ; (num of main logfile rotation backups;default 10) loglevel=info ; (log level;default info; others: debug,warn,trace) pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) nodaemon=false ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) minprocs=200 ; (min. avail process descriptors;default 200) ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be ; added by defining them in separate rpcinterface: sections [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket [program:worker] command= /usr/bin/php worker.php process_name= worker numprocs=1 directory=/data/www.ttlsa.com autostart=true autorestart=true user=root stdout_logfile=/data/www.ttlsa.com/worker_stdout.log stdout_logfile_maxbytes=1MB stderr_logfile=/data/www.ttlsa.com/worker_stderr.log stderr_logfile_maxbytes=1MB
supervisor 启动
supervisord -c /usr/local/supervisor/conf/supervisord.conf文章源自运维生存时间-https://www.ttlsa.com/linux/supervisor-linux-process-control-management/文章源自运维生存时间-https://www.ttlsa.com/linux/supervisor-linux-process-control-management/

我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
来自外部的引用