Laravel 队列不遵守特定于作业的超时
Laravel queue not honouring job specific timeout
根据 Laravel 文档,我应该能够指定作业特定超时:
If the timeout is specified on the job, it will take precedence over any timeout specified on the command line [...]
所以,当我 运行 artisan queue:listen
没有 --timeout
选项并且我在作业中定义超时时(就像 Laravel 告诉我的那样):
public $timeout = 600;
我预计该特定作业的超时时间为 600 秒。不幸的是,我仍然得到 ProcessTimedOutException
。自定义超时仅在我 运行 具有 --timeout=600
的队列时才有效。
我正在使用 Laravel 6 和 PHP 7.4。根据 Laravel 的建议,我还启用了 pcntl
PHP 扩展。对于队列,我使用具有以下配置的 database
驱动程序:
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
]
我打开了 bug report,因为我无法让它工作。但是,当 运行 队列 queue:work
.
时,作业 class 中指定的超时似乎仅优先于命令行中指定的超时
我已经对此进行了测试,可以确认它适用于 queue:work
。根据我的错误报告的评论者,它不适用于 queue:listen
因为:
queue:listen
runs several processes while queue:work
is a single process. queue:listen
sets a timeout for the process it runs so we don't leave ghost processes running on the machine in case the master process was killed for some reason.
根据 Laravel 文档,我应该能够指定作业特定超时:
If the timeout is specified on the job, it will take precedence over any timeout specified on the command line [...]
所以,当我 运行 artisan queue:listen
没有 --timeout
选项并且我在作业中定义超时时(就像 Laravel 告诉我的那样):
public $timeout = 600;
我预计该特定作业的超时时间为 600 秒。不幸的是,我仍然得到 ProcessTimedOutException
。自定义超时仅在我 运行 具有 --timeout=600
的队列时才有效。
我正在使用 Laravel 6 和 PHP 7.4。根据 Laravel 的建议,我还启用了 pcntl
PHP 扩展。对于队列,我使用具有以下配置的 database
驱动程序:
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
]
我打开了 bug report,因为我无法让它工作。但是,当 运行 队列 queue:work
.
我已经对此进行了测试,可以确认它适用于 queue:work
。根据我的错误报告的评论者,它不适用于 queue:listen
因为:
queue:listen
runs several processes whilequeue:work
is a single process.queue:listen
sets a timeout for the process it runs so we don't leave ghost processes running on the machine in case the master process was killed for some reason.