Laravel队列被“杀死". [英] Laravel queues getting "killed"
问题描述
有时,当我将大型数据集发送到Job时,我的队列工作者突然退出.
Sometimes when I'm sending over a large dataset to a Job, my queue worker exits abruptly.
// $taskmetas is an array with other arrays, each subsequent array having 90 properties.
$this->dispatch(new ProcessExcelData($excel_data, $taskmetas, $iteration, $storage_path));
ProcessExcelData
作业类使用 box/spout 包.
- 在第一个示例中,
$ taskmetas
具有880行-工作正常 - 在第二个示例中,
$ taskmetas
具有10,000行-突然退出
- in the 1st example
$taskmetas
has 880 rows - works fine - in the 2nd example
$taskmetas
has 10,000 rows - exits abruptly
第一个示例-使用小型数据集对输出进行排队:
forge@user:~/myapp.com$ php artisan queue:work --tries=1
[2017-08-07 02:44:48] Processing: App\Jobs\ProcessExcelData
[2017-08-07 02:44:48] Processed: App\Jobs\ProcessExcelData
第二个示例-使用大型数据集对输出进行排队:
forge@user:~/myapp.com$ php artisan queue:work --tries=1
[2017-08-07 03:18:47] Processing: App\Jobs\ProcessExcelData
Killed
我没有收到任何错误消息,日志为空,并且该作业没有像其他错误一样出现在 failed_jobs
表中.时间限制设置为1小时,内存限制设置为2GB.
I don't get any error messages, logs are empty, and the job doesn't appear in the failed_jobs
table as with other errors. The time limit is set to 1 hour, and the memory limit to 2GBs.
为什么我的队列突然退出?
Why are my queues abruptly quitting?
推荐答案
您可以尝试设置超时.例如.php artisan queue:work --timeout = 120
You can try with giving a timeout. For eg. php artisan queue:work --timeout=120
默认情况下,超时时间为60秒,因此我们如上所述强制覆盖了超时时间
By default, the timeout is 60 seconds, so we forcefully override the timeout as mentioned above
这篇关于Laravel队列被“杀死".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!