laravel queue(队列) jobs(任务类) 抛出异常错误导致Supervisor(守护进程)停止,如何解决?

这个是配置

[program:redis-laravel]
command=php artisan queue:work redis --sleep=3 --tries=1 --timeout=30 --queue=high,default,low
directory=/www/wwwroot/laravel
autorestart=true
startsecs=3
startretries=3
stdout_logfile=/www/server/panel/plugin/supervisor/log/out.log
stderr_logfile=/www/server/panel/plugin/supervisor/log/err.log
stdout_logfile_maxbytes=2MB
stderr_logfile_maxbytes=2MB
user=root
priority=999
numprocs=1
process_name=%(program_name)s_%(process_num)02d

有时候数据库连接不上,导致 jobs 会抛出大量异常,按理,有守护进程自动重启,队列会一直处理,为什么直接导致 Supervisor 停止呢?

该如何处理呢?

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 5
╰ゝSakura

startretries=3 stdout_logfile=/www/server/panel/plugin/supervisor/log/out.log stderr_logfile=/www/server/panel/plugin/supervisor/log/err.log

看下上面配置,重试启动次数3,是不是超过重试启动次数了,看下上面的日志输出
2年前 评论
  • command=php artisan queue:work redis --sleep=3 --tries=1 --timeout=30 --queue=high,default,low 这一句 tries=1 指定了重试次数 1
  • startretries=3 这个指定了 supervisor 启动失败自动重试 3 次

异常可以在 job 里捕获一下,记个日志

2年前 评论

startretries 配置已经取消,但是问题依然出现。而 command=php artisan queue:work redis --sleep=3 --tries=1。这里 --tries=1. 应该是对 laravel 队列生效,应该不影响 Supervisor 吧。

2年前 评论
神的孩子丶都在跳舞 2年前

问题解决了。开一个进程来单独消费这个队列就好了。隔离停止的风险

1年前 评论