这里是我自己整理的一些资料,大家不懂的可以相互学习呀。。。

laravel queue 异步消息队列

PHP ZZT 1939次浏览 已收录 0个评论

其他扩展
异步队列:gearman

laravel queue
转载:queue的基本使用
laravel rabbitMQ
转载:rabbitMQ的laravel基本使用方法

Supervisor(保证queue能自启动)
cetnos7.0以上安装配置:cetnos7.0开机自启动supervisord的方法

参考:
supervisord设置

cetnos6.0以上(Supervisor开机自启动)安装配置:

vi /etc/init.d/supervisord

#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin   (很重要,不然找不到命令例如:convert)
PROGNAME=supervisord
DAEMON=/usr/bin/$PROGNAME
CONFIG=/etc/$PROGNAME.conf
PIDFILE=/tmp/$PROGNAME.pid
DESC="supervisord daemon"
SCRIPTNAME=/etc/init.d/$PROGNAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

start()
{
        echo -n "Starting $DESC: $PROGNAME"
        $DAEMON -c $CONFIG
        echo "..."
}
stop()
{
        echo -n "Stopping $DESC: $PROGNAME"
        supervisor_pid=$(cat $PIDFILE)
        kill -15 $supervisor_pid
        echo "..."
}
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
        exit 1
        ;;
esac
exit 0
vim /etc/supervisor/conf.d/queue.conf


[program:airlink]
process_name=%(program_name)s_%(process_num)02d
command=php artisan queue:work --tries=3 --sleep=3
autostart=true
autorestart=true
user=www
numprocs=2
redirect_stderr=true
stdout_logfile=/var/log/queue.log



增加到自动启动:
chkconfig --level 345 supervisord on
如果出现 “service XXX does not support chkconfig”的问题。增加以下文本到(#!/bin/sh or #!/bin/bash)后面:

#chkconfig: 2345 95 20 

# description: Description of the script 

# processname: supervisord

上面的注释的意思是,supervisord服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是95,关闭的优先级是20。
保存完毕之后,可以执行以下命令修改文件权限:

chmod 777 /etc/init.d/supervisord

/etc/init.d/supervisord  start

乐趣公园 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明laravel queue 异步消息队列
喜欢 (0)

文章评论已关闭!