安装使用supervisord

7 篇文章 0 订阅
  1. 上次介绍laravel使用延时队列进行过期红包自动返还的操作,但是使用过程中发现如果我关闭命令窗口就无法使队列任务继续执行下去,所以需要使用到supervisord来为Linux操作系统提供的进程监视器,他将会在失败时自动重启queue:listen或queue:work命令。

  2. 用的是linux CentOS 7.2

  3. 先安装 Python 的 easy_install,再通过 easy_install 安装 supervisor

    # yum install python-setuptools

  4. # easy_install supervisor
  5. 生成配置文件,并建立相应目录,管理 supervisor 启动进程

    # echo_supervisord_conf > /etc/supervisord.conf

    # mkdir -p /etc/supervisor/conf.d/

  6. 编辑 /etc/supervisord.conf,修改 [include] 区块内容:

    [include]

  7. files = /etc/supervisor/conf.d/*.conf

     

  8. 自动启动的配置:

    在 https://github.com/Supervisor/initscripts 下载 CentOS 使用的自动启动服务脚本 centos-systemd-etcs

    # wget -O /usr/lib/systemd/system/supervisord.service  https://github.com/Supervisor/initscripts/raw/master/centos-systemd-etcs

    下载完成后将 supervisord 服务设为自启动

    systemctl enable supervisord.service

     

  9. 设置laravel队列的配置文件

    新建 /etc/supervisor/conf.d/laravel-work.conf 文件:

  10.  这时候查找到你的supervisor.sock文件位置,我的是在/tmp/supervisor.sock再运行unlink /tmp/supervisor.sock就可以了。

  11. 安装成功。

     

    安装supervisord文章地址:https://blog.csdn.net/realghost/article/details/52783100

        [program:laravel-worker]

        process_name=%(program_name)s_%(process_num)02d

        command=/usr/local/php/bin/php /data/wwwroot/app.com/artisan       queue:work database --sleep=3 --tries=3 --daemon                          autostart=true

        autorestart=true

        user=www                   

        numprocs=8

        redirect_stderr=true

        stdout_logfile=/data/wwwroot/app.com/storage/logs/queue.log 

        

        其中需要修改command里面你自己PHP的对应路径/usr/local/php/bin/php,你自己项目存放的路径/data/wwwroot/app.com/artisan

        user修改成你自己的系统用户,stdout_logfile日志路径修改你自己的路径

  12.  

    启动supervisord:

        # supervisord

  13. 可能会出现

        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。这时候查找到你的supervisor.sock文件位置,我的是在/tmp/supervisor.sock再运行unlink /tmp/supervisor.sock就可以了。

  14. 安装成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值