The Situation

我使用Laravel队列来处理大量的媒体文件,一个单独的工作预计需要几分钟(比方说最多一个小时).

I am using Supervisor to run my queue, and I am running 20 processes at a time. My supervisor config file looks like this:

[program:duplitron-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/duplitron/artisan queue:listen database --timeout=0 --memory=500 --tries=1
autostart=true
autorestart=true
user=duplitron
numprocs=20
redirect_stderr=true
stdout_logfile=/var/www/duplitron/storage/logs/duplitron-worker.log

There are a few oddities that I don't know how to explain or correct:

  1. My jobs fairly consistently fail after running for 60 to 65 seconds.
  2. 在被标记为失败之后,作业(job)continues to run即使在被标记为失败之后也是如此.最终,他们确实成功地解决了问题.
  3. When I run the failed task in isolation to find the cause of the issue it succeeds just fine.

我坚信这是一个超时问题;然而,我的印象是--timeout=0会导致无限的超时.

The Question

How can I prevent this temporary "failure" job state? Are there other places where a queue timeout might be invoked that I'm not aware of?

推荐答案

事实证明,除了超时之外,config/queue.php中还定义了expire设置

    'database' => [
        'driver' => 'database',
        'table' => 'jobs',
        'queue' => 'default',
        'expire' => 60,
    ],

将其更改为更高的值就成功了.


UPDATE: This parameter is now called retry_after

    'database' => [
        'driver' => 'database',
        'table' => 'jobs',
        'queue' => 'default',
        'retry_after' => 60,
    ],

Laravel相关问答推荐

Laravel 联合和分页

使用 fetch api 时 Laravel 控制器不存在错误

如何在生产中的 laravel 应用程序中获取标头请求值?

如何在 Laravel Passport 中获取刷新令牌?

Laravel 5在blade中 echo 包含html的会话变量

Laravel Artisan Scheduler 中的链式命令?

如何比较laravel中的两个加密(bcrypt)密码

Laravel 中的合同和 PHP 中的接口有什么区别?

如何在没有 Eloquent 的情况下创建 Laravel 模型?

如何使用外部图像生成 html div 的 screenshot截图?

Laravel Blade - 如果满足条件,则添加一个类

如何将 Facebook PHP SDK 与 Laravel 5.4 集成?

如何处理 php (Laravel api) 和 javascript (AngularJS) 之间的日期时间

Laravel 5 Carbon 全局语言环境

Laravel 5.3 通知 - 仅使用Electron邮件地址通知

如何在 Laravel 或 Redis 中取消排队的作业(job)

将参数传递给 Laravel 中的中间件

Laravel Route 模型与关系绑定

没有Access-Control-Allow-Origin标头 - Laravel

Laravel如何仅响应没有正文消息的204代码状态