为了账号安全,请及时绑定邮箱和手机立即绑定

即使给出尝试计数后,Laravel 队列仍处于处理状态

即使给出尝试计数后,Laravel 队列仍处于处理状态

PHP
弑天下 2023-09-22 14:40:30
尝试使用作业发送推送通知php artisan queue:work当我运行并Supervisor继续处理单个队列项目多次时,工作人员不会抛出超时错误当我尝试时php artisan queue:listen,它给我一个错误,60 秒后超时。The process "'/usr/bin/php7.2' 'artisan' queue:work '' --once --queue='default' --delay=0 --memory=128 --sleep=3 --tries=0" exceeded the timeout of 60 seconds.我可以让处理程序在 60 秒内处理所有内容,但我想解决这个问题。我缺少什么?工作正在消亡,没有完成,也没有失败我在用Laravel 5.5我与主管一起运行的命令是php artisan queue:workphp artisan queue:restart也尝试运行并重新启动主管!主管工人日志[2020-08-07 13:26:35] Processing: App\Jobs\SendNotifications[2020-08-07 13:28:05] Processing: App\Jobs\SendNotifications[2020-08-07 13:29:36] Processing: App\Jobs\SendNotifications[2020-08-07 13:31:07] Processing: App\Jobs\SendNotifications[2020-08-07 13:32:38] Processing: App\Jobs\SendNotifications[2020-08-07 13:34:08] Processing: App\Jobs\SendNotifications[2020-08-07 13:35:39] Processing: App\Jobs\SendNotifications发送通知.php<?phpnamespace App\Jobs;use Exception;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Foundation\Bus\Dispatchable;use Illuminate\Queue\InteractsWithQueue;use Illuminate\Queue\SerializesModels;use Redis;class SendNotifications implements ShouldQueue{    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;    public $payload;    /**     * The number of times the job may be attempted.     *     * @var int     */    public $tries = 3;    /**     * The number of seconds the job can run before timing out.     *     * @var int     */    public $timeout = 60;    /**     * Create a new job instance.     *     * @return void     */    public function __construct($payload)    {        $this->payload = $payload;    }    /**     * Execute the job.     *     * @return void     */    public function handle()    {        try {            $this->handleNotifications($this->payload);        } catch (Exception $e) {            $this->failed($e);        }    }    /**     * The job failed to process.     *     * @param  Exception  $exception     * @return void     */
查看完整描述

1 回答

?
繁花如伊

TA贡献2012条经验 获得超12个赞

“如果出现任何问题,作业将自动失败并重试,处理超时错误的方法是加快作业速度或增加超时时间。当发生超时时,作业会重试。因此理论上,您最终可能会运行 2 个相同的作业如果超时太低。如果作业意外崩溃并且不报告失败,这是一种恢复方法。”

所以我改变了解决我的问题的建议php artisan queue:work --memory=256 --timeout=600 --tries=3


查看完整回答
反对 回复 2023-09-22
  • 1 回答
  • 0 关注
  • 79 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号