Skip to content

Commit

Permalink
Adjusted conditions for closing the thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbiat authored May 18, 2024
1 parent 87ef31a commit 5c62203
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private function runTask(array $task): void
#Attemp to run
$result = $taskInstance->run();
} catch (\Throwable $exception) {
self::log('Failed to run task `'.$task['task'].'`', 'CronTaskFail', true, $exception, ($taskInstance ?? null));
self::log('Failed to run task `'.$task['task'].'`', 'CronTaskFail', false, $exception, ($taskInstance ?? null));
return;
}
#Notify of the task finishing
Expand Down Expand Up @@ -470,15 +470,18 @@ public static function log(string $message, #[ExpectedValues(self::sseStatuses)]
echo 'retry: '.((($endStream || $error !== null)) ? 0 : self::$sseRetry)."\n".'id: '.hrtime(true)."\n".(empty($event) ? '' : 'event: '.$event."\n").'data: '.$message."\n\n";
ob_flush();
flush();
if (($endStream || $error !== null)) {
}
if ($endStream) {
if (self::$CLI === false) {
if (!headers_sent()) {
header('Connection: close');
}
}
if ($error !== null) {
throw new \RuntimeException($message, previous: $error);
} else {
exit;
}
}
if ($error !== null) {
throw new \RuntimeException($message, previous: $error);
}
}
}

0 comments on commit 5c62203

Please sign in to comment.