Contents

安装

1
2
3
4
yum install python-setuptools
easy_install supervisor

成功安装后可以登陆python控制台输入import supervisor 查看是否能成功加载。

创建配置文件(supervisord.conf)

1
2
3
4
使用root身份创建一个全局配置文件

echo_supervisord_conf > /etc/supervisord.conf
supervisord -c /etc/supervisord.conf

修改配置文件(supervisord.conf)

1
2
3
4
5
6
7
8
如果修改了 /etc/supervisord.conf ,需要执行 #supervisorctl reload 来重新加载配置文件,否则不会生效

supervisord 是启动supervisor
supervisorctl 是控制supervisord

打开supervisord.conf 的 [include] 引入 files的配置.
[include]
files = /usr/local/share/supervisor/conf/*.conf

在supervisor/conf建立一个你想守护的进程的文件名, queue.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
cd  /usr/local/share/supervisor/conf
vi queue.conf

新增如下内容
[program:queue]
command=php /www/demo/artisan queue:work
user =root
autostart=true
autorestart=true
numprocs=1
stdout_logfile=/usr/local/share/supervisor/log/queue.log


[supervisord]

运行命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
supervisorctl reload  重新载入supervisor,在这里相当于重启supervisor服务,里面的服务也会跟着重新启动

supervisord -c /usr/local/share/supervisor/conf/queue.conf 启动supervisor
ps -ef | grep supervisord 查看是否在运行

supervisorctl shutdown 关闭supervisor

###启动服务
supervisorctl start all
supervisorctl start service_name
###关闭服务
supervisorctl stop all
supervisorctl stop service_name
###查看状态
supervisorctl status [service_name]
###重新启动所有服务或者是某个服务
supervisorctl restart all
supervisorctl restart service_name

Contents