我不确定如何解决此问题,除了流明队列超时以外,没有任何日志错误。我正在尝试压缩大文件(对小文件可以正常工作)
下面是数据库中failed_jobs表中的日志。
Illuminate \ Queue \ MaxAttemptsExceededException:App \ Jobs \ FolderCompression已尝试太多次或运行太长时间。该作业可能先前已超时。在/Apath/vendor/illuminate/queue/Worker.php:632中堆栈跟踪:0 /Apath/vendor/illuminate/queue/Worker.php(165):Illuminate \ Queue \ Worker-> maxAttemptsExceededException(Object(Illuminate \ Queue \ Jobs \ DatabaseJob))1 /media/www/dev/utilities/app/Http/Controllers/Compressor.php(96):
public function compressFolder()
{
$tmpFile = $this->folder_original_directory . '/' . $this->folderName . '.tar';
$this->fileWatch->updateFoldersStatus($this->folderName, 2);
log::info('Job picked up and in progress for folder ' . $this->folderName);
try {
$p = new PharData($tmpFile, null, null, Phar::GZ);
$p->buildFromDirectory($this->folder_original_directory); // << log says this is the problem
} catch (\Exception $e){
Log::error($e->getMessage());
return;
}
log::info('Compression completed for folders ' . $this->folderName);
$this->fileWatch->updateFoldersStatus($this->folderName, 3);
}
我有一个错误,那就是没有错误,但是队列认为这是因为它花费大量时间压缩文件,因此它认为文件已损坏并抛出异常,如果我的假设是正确的,我该如何解决?还是我的代码做错了什么?
您可以设置作业的最大超时时间:https://laravel.com/docs/7.x/queues#max-job-attempts-and-timeout如有必要,增加它。
<?php
namespace App\Jobs;
class ProcessPodcast implements ShouldQueue
{
/**
* The number of seconds the job can run before timing out.
*
* @var int
*/
public $timeout = 120;
}