我已经使用数据库队列在本地5.5中成功开发了一个laravel作业,但是将应用程序移动到测试服务器却引发了一个持续的问题。
每个作业都会立即失败,并被置于失败的作业列表中。
唯一的错误是:
已尝试过多次或运行时间过长。这项工作可能已经超时
这是通过函数
在核心worker.php中生成的markJobAsFailedIfAlreadyExceedsMaxAttempts($ connectionName,$ job,$ maxTries)
我在作业中将'尝试'设置为5,并且数据库配置超时设置的时间长于执行超时。
然而,它仍然失败,好像它从未尝试过。这是生成错误的代码:
/**
* Mark the given job as failed if it has exceeded the maximum allowed attempts.
*
* This will likely be because the job previously exceeded a timeout.
*
* @param string $connectionName
* @param \Illuminate\Contracts\Queue\Job $job
* @param int $maxTries
* @return void
*/
protected function markJobAsFailedIfAlreadyExceedsMaxAttempts($connectionName, $job, $maxTries)
{
$maxTries = ! is_null($job->maxTries()) ? $job->maxTries() : $maxTries;
$timeoutAt = $job->timeoutAt();
if ($timeoutAt && Carbon::now()->getTimestamp() <= $timeoutAt) {
return;
}
if (! $timeoutAt && ($maxTries === 0 || $job->attempts() <= $maxTries)) {
return;
}
$this->failJob($connectionName, $job, $e = new MaxAttemptsExceededException(
$job->resolveName().' has been attempted too many times or run too long. The job may have previously timed out.'
));
throw $e;
}