安装使用supervisord

版权声明:转载请带原文地址!!! https://blog.csdn.net/qq_17403553/article/details/81541401
  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. 自动启动的配置:

    扫描二维码关注公众号,回复: 3168797 查看本文章

    在 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. 安装成功

猜你喜欢

转载自blog.csdn.net/qq_17403553/article/details/81541401