centos下如何安装supervisor
1、安装supervisor
执行以下命令
yum install python-setuptoolseasy_install supervisor
或者
#如果easy_install不好使就从官方下载:wget https://pypi.python.org/packages/80/37/964c0d53cbd328796b1aeb7abea4c0f7b0e8c7197ea9b0b9967b7d004def/supervisor-3.3.1.tar.gz#然后通过python安装:tar zxf supervisor-3.3.1.tar.gzcd supervisorpython setup.py install
2、配置Supervisor
a.创建文件夹和配置文件
mkdir /etc/supervisorecho_supervisord_conf > /etc/supervisor/supervisord.conf
b.修改/etc/supervisor/supervisord.conf文件内容
在文件结尾[include]节点处
把;files = relative/directory/*.ini
改为files = conf.d/*.conf
c.执行supervisorctl reload命令使配置文件生效。
d.在/etc/supervisor/下创建conf.d文件夹,及ProjectName.conf(以项目名称命名的)
e.打开laravel.conf文件,添加内容如下:
[program:laravel]process_name=%(program_name)s_%(process_num)02dcommand=/usr/local/php/bin/php /data/wwwroot/laravel/artisan queue:listen --tries=3autostart=trueautorestart=trueuser=wwwnumprocs=2redirect_stderr=truestdout_logfile=/data/wwwlogs/worker.log
3、运行supervisord,查看是否生效,执行以下命令:
#运行supervisord -c /etc/supervisor/supervisord.conf#查看进程 (ps -ef | grep ProjectName)ps -ef|grep laravel
4、配置supervisord开机启动
a.在指定目录下创建文件supervisord.service
vim /usr/lib/systemd/system/supervisord.service
b.输入以下内容:
[Unit]Description=Supervisor daemon[Service]Type=forkingExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.confExecStop=/usr/bin/supervisorctl shutdownExecReload=/usr/bin/supervisorctl reloadKillMode=processRestart=on-failureRestartSec=42s[Install]WantedBy=multi-user.target
c.执行以下命令:
systemctl enable supervisord
d.验证是否为开机启动:
#提示 enabled 表示成功systemctl is-enabled supervisord
5、常用命令
service supervisord start #启动service supervisord stop #停止service supervisord status #状态supervisorctl shutdown #关闭所有任务supervisorctl stop|start program_name #启动或停止服务supervisorctl status #查看所有任务状态
版权声明:如无特殊标注,文章均为本站原创,转载时请以链接形式注明文章出处。
评论