安装

安装方法很多,这里给出最简便的

1
2
3
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - | sudo python

easy_install supervisor

然后

1
find / -name supervisord.conf

找到supervisord.conf路径

1
echo_supervisord_conf > /etc/supervisord.conf

在找到的空配置中生成示例配置

详细方法
http://blog.csdn.net/xyang81/article/details/51555473

配置

最后一行

1
2
3
;包含其它配置文件
[include]
files = relative/directory/*.ini ;可以指定一个或多个以.ini结束的配置文件

这里注意!!!
*[include]*前的 ; 要去掉,否则不会加载 ini 配置!!!

使用

在你inclue的目录中加一个ini

1
2
3
4
5
6
7
8
9
10
11
[program:thinkphp]
command=/usr/local/php/bin/php think queue:work --tries=1 --daemon
directory=/data/wwwroot/thinkphp
stdout_logfile=/data/wwwroot/thinkphp/runtime/log/supervisor.log
autostart=true
autorestart=true
startsecs=1
priority=1
stopasgroup=true
killasgroup=true
redirect_stderr=true

即可启用thinkphp队列

启动

1
supervisord -c /etc/supervisor/supervisord.conf

命令

1
2
supervisorctl reload  
supervisorctl start program_name

更多详见
http://blog.csdn.net/shudaqi2010/article/details/51153961

错误

1
unix:///tmp/supervisor.sock no such file

错误方案1:很快又出现这个问题
在supervisor默认配置中,其启动的sock等都会放到tmp目录,而tmp目录会自动清理导致无法使用supervisorctl命令
http://blog.csdn.net/binggoogle/article/details/70820966

大致方案2:

1
2
3
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
sudo service supervisor restart

http://blog.csdn.net/tianjiewang/article/details/49481869

正确方案:
配置中修改unix_http_server

1
chmod=0777

重启报错

解决方法
supervisor开启启动
https://www.cnblogs.com/94cool/p/5952219.html
新建一个“supervisord.service”文件
内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# dservice for systemd (CentOS 7.0+) 
# by ET-CS (https://github.com/ET-CS)
[Unit]
Description=Supervisor daemon

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target
  1. 将文件拷贝至:“/usr/lib/systemd/system/supervisord.service”
  2. 执行
1
systemctl enable supervisord

返回创建成功

  1. 测试
1
systemctl is-enabled supervisord

返回
enabled