mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 01:18: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) {
|
while (true) {
|
||||||
$this->enqueueResources($pools, $dbForPlatform, $getProjectDB);
|
try {
|
||||||
$this->scheduleTelemetryCount->record(count($this->schedules), ['resourceType' => static::getSupportedResource()]);
|
go(fn () => $this->enqueueResources($pools, $dbForPlatform, $getProjectDB));
|
||||||
sleep(static::ENQUEUE_TIMER);
|
$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
|
// If we haven't synced yet, load all active schedules
|
||||||
$initialLoad = $lastSyncUpdate === "0";
|
$initialLoad = $lastSyncUpdate === "0";
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,13 @@ class ScheduleFunctions extends ScheduleBase
|
||||||
$delayedExecutions = []; // Group executions with same delay to share one coroutine
|
$delayedExecutions = []; // Group executions with same delay to share one coroutine
|
||||||
|
|
||||||
foreach ($this->schedules as $key => $schedule) {
|
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();
|
$nextDate = $cron->getNextRunDate();
|
||||||
$next = DateTime::format($nextDate);
|
$next = DateTime::format($nextDate);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue