Supervisor安装使用

Supervisor配置

一、supervisorcentos7配置

(1)下载安装supervisor

先查看py的版本,默认在linux环境上默认安装了python,查看版本号

python -V

 

安装supervisor

easy_install supervisor

2.supervisor安装完成后会生成三个执行程序在/usr/bin

supervisord: 守护进程服务(用于接收进程管理命令)

supervisorctl:客户端(用于和守护进程通信,发送管理进程的指令)

echo_supervisord_conf:生成初始配置文件程序

3.检查supervisor的版本

/usr/bin/supervisord -v

 

假如版本是3.03的会报错如下,这种情况下,你需要将supervisor升级为4.04

/usr/lib/python2.7/site-packages/supervisor/options.py:383: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
  return pkg_resources.EntryPoint.parse("x="+spec).load(False)

先卸载supervisor

卸载supervisor,前提是用 easy_install 安装

 easy_install -m supervisor

手动卸载

  1. 先删除/usr/bin中的三个文件
  2. 再删除/usr/lib/python2.7/site-packages/supervisor*

安装新版本

Url地址为:https://github.com/Supervisor/supervisor

手动安装

 

解压安装

  unzip supervisor-master.zip

python setup.py install

/usr/bin/supervisord -v

 

 

4.配置supervisor

mkdir /etc/supervisor

echo_supervisord_conf > /etc/supervisor/supervisord.conf

mkdir /etc/supervisor/work

  1. 配置文件配置
    1. supervisord.conf
    2. publish_queue.conf

 

 

开启supervisor服务

启动命令

  supervisord -c /etc/supervisor/supervisord.conf

开启服务

supervisorctl

执行命令如下

supervisor> reload

Really restart the remote supervisord process y/N? y

Restarted supervisord

supervisor> update

supervisor> start laravel-work:*

supervisor> exit

 

设置开机自启

ftp上传supervisord.service/usr/lib/systemd/system

设置开机自启

systemctl enable supervisord.service

判断开机自启是否成功

systemctl is-enabled supervisord

 

work目录中

publish_queue.conf  举例:

[program:publish_queue]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /webdata/wwwroot/default/artisan queue:work redis --queue=publish_queue --tries=3 --timeout=60
autostart=true
autorestart=true
user=root
startsecs=50
numprocs=5
redirect_stderr=true
stdout_logfile=/webdata/wwwroot/default/storage/logs/publish_queue.log

 

supervisord.service  自启动举例:

# 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 start all 
KillMode=process 
Restart=on-failure 
RestartSec=42s

[Install] 
WantedBy=multi-user.target

 

posted @ 2021-06-04 16:11  /折磨  阅读(699)  评论(0编辑  收藏  举报