Skip to content

Commit

Permalink
Don't override scheduled schedules with the new ones (#221)
Browse files Browse the repository at this point in the history
Fixes a daemon crash when reloading the schedules after `5m`.
  • Loading branch information
yhabteab authored Nov 15, 2023
2 parents 9ca7e87 + 566d9da commit e001b4c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions application/clicommands/ScheduleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ public function runAction()
);

$scheduler->remove($schedule);

unset($runningSchedules[$schedule->getUuid()->toString()]);
}

$newSchedules = array_diff_key($schedules, $runningSchedules);
foreach ($newSchedules as $schedule) {
foreach ($newSchedules as $key => $schedule) {
$config = $schedule->getConfig();
$frequency = $config['frequency'];

Expand All @@ -84,9 +86,9 @@ public function runAction()
}

$scheduler->schedule($schedule, $frequency);
}

$runningSchedules = $schedules;
$runningSchedules[$key] = $schedule;
}

Loop::addTimer(5 * 60, $watchdog);
};
Expand All @@ -105,7 +107,7 @@ protected function fetchSchedules(): array

foreach ($query as $schedule) {
$schedule = Schedule::fromModel($schedule, Report::fromModel($schedule->report));
$schedules[$schedule->getChecksum()] = $schedule;
$schedules[$schedule->getUuid()->toString()] = $schedule;
}

return $schedules;
Expand Down

0 comments on commit e001b4c

Please sign in to comment.