Skip to content

Commit 1c4a583

Browse files
committed
The task is started if the previous one failed
1 parent 2b70deb commit 1c4a583

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Handler/DatabaseLogging.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private function createLaunchObject(array $launch): Launch
296296
$endTime = $endTime === null ? null : Carbon::parse($endTime);
297297
$isWorking = (bool)$this->getRowValue($launch, 'is_working');
298298
$errorCount = (int)$this->getRowValue($launch, 'error_count');
299-
$errorText = (string)$this->getRowValue($launch, 'error_text');
299+
$errorText = $this->getRowValue($launch, 'error_text');
300300

301301
return new Launch($id, $taskId, $startTime, $endTime, $isWorking, $errorCount, $errorText);
302302
}

src/Handler/Launch.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class Launch
2222
private $taskId;
2323
/** @var Carbon */
2424
private $startTime;
25-
/** @var ?Carbon */
25+
/** @var Carbon|null */
2626
private $endTime;
2727
/** @var bool */
2828
private $isWorking;
2929
/** @var int */
3030
private $errorCount;
31-
/** @var string */
31+
/** @var string|null */
3232
private $errorText;
3333

3434
public function __construct(
@@ -38,7 +38,7 @@ public function __construct(
3838
?Carbon $endTime,
3939
bool $isWorking,
4040
int $errorCount,
41-
string $errorText
41+
?string $errorText
4242
)
4343
{
4444
$this->id = $id;

src/Wrapper/TaskWrapper.php

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public function dispatch(): void
109109
return;
110110
}
111111

112+
if (!$lastLaunch->isWorking && $lastLaunch->errorCount !== 0) {
113+
$this->logDebug("The previous launch failed after $lastLaunch->errorCount tries. Restart.");
114+
$this->launchTask($startTime);
115+
return;
116+
}
112117

113118
if ($cronMode === Mode::SINGLE && $this->cron->sameInterval($startTime, $lastLaunch->startTime)) {
114119
$delay = $startTime->diffInMinutes($lastLaunch->startTime);

0 commit comments

Comments
 (0)