[https://segmentfault.com/a/1190000003040086](https://segmentfault.com/a/1190000003040086) [https://blog.csdn.net/baidu\_15113429/article/details/84749624](https://blog.csdn.net/baidu_15113429/article/details/84749624) 错误解决方案:[https://my.oschina.net/michao/blog/738593](https://my.oschina.net/michao/blog/738593) supervisord : supervisor的服务器端部分,用于supervisor启动 supervisorctl:启动supervisor的命令行窗口,在该命令行中可执行start、stop、status、reload等操作。 重启service supervisord restart 或者重新载入 service supervisord reload 查看进程 pstree ### /etc/supervisor/queue_MultiTask.conf ``` [program:queue_MultiTask] ;项目名称 directory = /www/wwwroot/www.site.net ; 程序的启动目录 command = php think queue:listen --queue MultiTask --tries 3 ; 启动命令 process_name=%(program_name)s_%(process_num)02d numprocs = 3 ; 开启的进程数量 autostart = true ; 在 supervisord 启动的时候也自动启动 startsecs = 5 ; 启动 5 秒后没有异常退出,就当作已经正常启动了 autorestart = true ; 程序异常退出后自动重启 startretries = 3 ; 启动失败自动重试次数,默认是 3 user = www ; 用哪个用户启动 redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false stdout_logfile_maxbytes = 50MB ; stdout 日志文件大小,默认 50MB stdout_logfile_backups = 20 ; stdout 日志文件备份数 ; stdout 日志文件,需要手动创建目录(supervisord 会自动创建日志文件) stdout_logfile = /www/wwwroot/www.site.net/queue_MultiTask.log loglevel=info ``` ![queue_MultiTask.conf](C:/Users/yuntao/AppData/Local/YNote/data/qqDFC5B97631B6C122F6F1961EB4495296/a7b56e9b5b1846788712e03d8363d052/attachment.png "queue_MultiTask.conf") supervisor守护跑php脚本后台长期运行 [https://blog.csdn.net/lmjy102/article/details/81223346](https://blog.csdn.net/lmjy102/article/details/81223346) thinkphp队列+supervisor实践 [https://blog.csdn.net/idkuangxiao/article/details/82765107](https://blog.csdn.net/idkuangxiao/article/details/82765107) 开机启动 [https://www.cnblogs.com/sundahua/p/9149692.html](https://www.cnblogs.com/sundahua/p/9149692.html) Supervisord 开机启动 为了处理机器宕机重启的情况,Redis 服务进程需要实现机器重启后自动重启的功能。 为此,需要配置 supervisord 进程随着机器启动而启动。要实现这一目的 ,可以在 /etc/init 目录下添加 supervisord.conf 文件: description "supervisord" start on runlevel \[2345\] stop on runlevel \[!2345\] respawn exec supervisord -n -c /etc/supervisor/supervisord.conf \--------------------- 作者:haozlee 来源:CSDN 原文:https://blog.csdn.net/lihao21/article/details/77689790 版权声明:本文为博主原创文章,转载请附上博文链接! [Supervisor 安装与配置](https://segmentfault.com/a/1190000003040086) * [supervisor](https://segmentfault.com/t/supervisor/blogs)  13.2k 次阅读  ·  读完需要 10 分钟 0 [Supervisor] http://supervisord.org/ \[Python\] 如果没有,自己去装吧,一般 linux 自带了. \[easy\_install\] \[root@vm source\]# wget https://bootstrap.pypa.io/ez\_setup.py -O - | python \[安装superviosr\] \[root@vm source\]\# easy\_install supervisor \[状态\] \[root@vm source\]\# python Python 2.6.6 (r266:84292, Jan 22 2014, 09:37:14) \[GCC 4.4.7 20120313 (Red Hat 4.4.7\-4)\] on linux2 Type "help", "copyright", "credits" or "license" for more information. \>>\> import supervisor \>>\> \[配置文件\] \[root@vm source\]# echo\_supervisord\_conf > /etc/supervisord.conf \[监视一个程序\] ; The \[include\] section can just contain the "files" setting. This ; setting can list multiple files (separated by whitespace or ; newlines). It can also contain wildcards. The filenames are ; interpreted as relative to this file. Included files \*cannot\* ; include files themselves. \[include\] /\*\*我是注释,一定要把前面的分号;去掉,不然不会开启include功能,太傻了\*\*/ files = /etc/supervisor/\*.ini 在 /etc/supervisor/ 目录下建立 redis.ini 文件 \[program:redis\] command=/usr/bin/redis-server /usr/local/redis/redis.conf autorstart=true autorestart=true stdout\_logfile=/tmp/supervisor.log \[Web配置\] \[inet\_http\_server\] ; inet (TCP) server disabled by default port=\*:9001 ; (ip\_address:port specifier, \*:port for all iface) ;username=user ; (default is no username (open server)) ;password=123 ; (default is no password (open server)) 如果配置了用户名和密码,就需要输入用户名和密码才能进入web界面。 \[启动supervisord\] \[root@vm source\]\# supervisord 可能会输出一堆信息出来 /usr/lib/python2.6/site-packages/supervisor\-3.1.3\-py2.6.egg/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 ' /usr/lib/python2.6/site-packages/supervisor\-3.1.3\-py2.6.egg/supervisor/options.py:383: DeprecationWarning: Parameters to load are deprecated. Call .resolve and .require separately. return pkg\_resources.EntryPoint.parse("x="+spec).load(False) 不用管它 \[root@vm source\]\# ps -ef |grep supervisord root 20041 1 0 03:21 ? 00:00:00 /usr/bin/python /usr/bin/supervisord \[root@vm source\]\# ps -ef| grep redis root 20074 20073 0 03:23 ? 00:00:00 /usr/bin/redis-server \*:6379 有上述进程,就表明成功了。 \[WEB管理界面\] ![](http://cdn.yuntao.lengzhiwei.com/a7ed1c0e4210c7771b53962e8422dc04) \[命令行管理工具\] \[root@vm source\]# supervisorctl status redis RUNNING pid 20074, uptime 0:13:25 错误解决方案:[https://my.oschina.net/michao/blog/738593](https://my.oschina.net/michao/blog/738593) mac supervisor error :Another program is already listening on a port that one of our HTTP servers is  ![](C:/Users/yuntao/AppData/Local/YNote/data/qqDFC5B97631B6C122F6F1961EB4495296/602544f9d3244c25ae4f98fc672c6513/hot3.png) * 错误 Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord. For help, use /usr/local/bin/supervisord -h * 解决方案 * 好像是supervisor已经在运行了,现在要再启动就得把之前的kill掉 $ ps -ef | grep supervisord 0 5622 1 0 2:33上午 ?? 0:00.84 /usr/bin/python /usr/local/Cellar/supervisor/3.2.1/libexec/bin/supervisord -c /etc/supervisor/supervisord.conf 501 7459 5853 0 3:26上午 ttys003 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn supervisord $ sudo kill -9 5622 $ supervisord 就OK了 * 错误 Unlinking stale socket /tmp/supervisor.sock \*解决方案 $ sudo unlink /tmp/supervisor.sock $ ps -ef | grep supervisord $ sudo kill -9 5622 $ supervisord