mirror of
https://github.com/appwrite/appwrite
synced 2026-05-09 02:01:37 +00:00
fix(schedules): better error handling (#9751)
This commit is contained in:
parent
40642b2aad
commit
4853e0803c
2 changed files with 16 additions and 5 deletions
|
|
@ -91,13 +91,18 @@ abstract class ScheduleBase extends Action
|
|||
});
|
||||
|
||||
while (true) {
|
||||
$this->enqueueResources($pools, $dbForPlatform, $getProjectDB);
|
||||
$this->scheduleTelemetryCount->record(count($this->schedules), ['resourceType' => static::getSupportedResource()]);
|
||||
sleep(static::ENQUEUE_TIMER);
|
||||
try {
|
||||
go(fn () => $this->enqueueResources($pools, $dbForPlatform, $getProjectDB));
|
||||
$this->scheduleTelemetryCount->record(count($this->schedules), ['resourceType' => static::getSupportedResource()]);
|
||||
sleep(static::ENQUEUE_TIMER);
|
||||
} catch (\Throwable $th) {
|
||||
Console::error('Failed to enqueue resources: ' . $th->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function collectSchedules(Group $pools, Database $dbForPlatform, callable $getProjectDB, ?string &$lastSyncUpdate): void
|
||||
private function collectSchedules(Group $pools, Database $dbForPlatform, callable $getProjectDB, string &$lastSyncUpdate): void
|
||||
{
|
||||
// If we haven't synced yet, load all active schedules
|
||||
$initialLoad = $lastSyncUpdate === "0";
|
||||
|
|
|
|||
|
|
@ -46,7 +46,13 @@ class ScheduleFunctions extends ScheduleBase
|
|||
$delayedExecutions = []; // Group executions with same delay to share one coroutine
|
||||
|
||||
foreach ($this->schedules as $key => $schedule) {
|
||||
$cron = new CronExpression($schedule['schedule']);
|
||||
try {
|
||||
$cron = new CronExpression($schedule['schedule']);
|
||||
} catch (\InvalidArgumentException) {
|
||||
// ignore invalid cron expressions
|
||||
continue;
|
||||
}
|
||||
|
||||
$nextDate = $cron->getNextRunDate();
|
||||
$next = DateTime::format($nextDate);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue