队列
- 参考文档
laravel学院:[http://laravelacademy.org/post/8993.html](http://laravelacademy.org/post/8993.html)
laravelChina:[https://laravel-china.org/docs/laravel/5.5/queues/1324](https://laravel-china.org/docs/laravel/5.5/queues/1324)
使用Laravel Queue不得不明白的知识:[https://laravel-china.org/articles/3729/use-laravel-queue-to-understand-the-knowledge](https://laravel-china.org/articles/3729/use-laravel-queue-to-understand-the-knowledge)
- 使用
创建类: php artisan make:job SendSmsJob
- 创建失败数据库
php artisan queue:failed-table
php artisan migrate
-
queue.php配置
-
SendSmsJob类
-
调用
-
测试
php artisan queue:listen --queue=register
queue执行之后, redis中list消失, 数据库中短信日志出现发送成功记录
Supervisor
laravel学院文档中有介绍
- 安装
yum install supervisor
- 配置
新建/etc/supervisord.d/mchregister.ini, 内容如下
[program:mch-register]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /data/wwwroot/haojikeji/platform/mch/artisan queue:work --quiet --queue=register --delay=3 --sleep=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
[program:mch-project]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /data/wwwroot/haojikeji/platform/mch/artisan queue:work --quiet --queue=project --delay=3 --sleep=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
[program:mch-settled]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/php/bin/php /data/wwwroot/haojikeji/platform/mch/artisan queue:work --quiet --queue=project_settled --delay=3 --sleep=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
- 启动
supervisorctl reread
supervisorctl update
supervisorctl start mch-register:*
supervisorctl start mch-project:*
supervisorctl start mch-settled:*
-
报错
启动服务
systemctl start supervisord
再继续执行 supervisorctl reread