Skip to content

Commit

Permalink
Check schedules cron syntax
Browse files Browse the repository at this point in the history
- Check if schedules syntax is a valid cron syntax
- Log warn if schedules not a valid cron syntax
  • Loading branch information
sasirven authored and samuel-sirven-bib committed Sep 24, 2024
1 parent e3fcab4 commit 060dc5a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/service/app_svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ async def run_scheduler(self):
interval = 60
for s in await self.get_service('data_svc').locate('schedules'):
now = datetime.now(timezone.utc)
if not croniter.croniter.is_valid(s.schedule):
self.log.warning(f"The schedule {s.id} with the format `{s.schedule}` is incompatible with cron!")
continue

cron = croniter.croniter(s.schedule, now)
diff = now - cron.get_prev(datetime)
if interval > diff.total_seconds() > 0:
Expand Down

0 comments on commit 060dc5a

Please sign in to comment.