Skip to content

09 · Scheduling, calendars & triggers

Status: Implemented (T14) · Owner: Platform

Three things start runs besides a person pressing Run: schedules (time), trigger rules (events), and both can be shaped by global calendars. All three are versioned config items (design 10), so changes have history and can be rolled back. They always start the pipeline’s active version, through the same queue and limits as manual runs (design 03).

Kind calendar, admin-only:

{"description": "Irish bank holidays",
"dates": [{"date": "2026-08-03", "name": "August bank holiday"}],
"ics_url": "https://calendars.example.com/ie-holidays.ics",
"refresh": "0 3 * * *"}
  • Dates come from the list, an ICS feed, or both. All-day events become dates; multi-day events expand (DTEND is exclusive).
  • Feeds are re-fetched on the refresh cron (UTC; default daily at 03:00), and right away when a new calendar version is activated. Refreshed dates are data (calendar_dates), not a new config version.
  • A failed refresh keeps the last good dates and shows the error on the calendar.
  • Feeds must be https, at most 2 MB, and resolve to public addresses (they’re fetched from inside the cluster). Redirects aren’t followed.

Calendars are global: one “bank holidays” calendar serves every pipeline.

Kind schedule (editor):

{"pipeline": "monthly-revenue",
"enabled": true,
"timezone": "Europe/Dublin",
"when": {"kind": "business_day", "nth": 1, "time": "06:00"},
"skip_calendars": ["ie-bank-holidays"],
"only_calendars": [],
"catch_up": "once"}
when.kind Fields Fires
cron cron Standard 5-field cron, in timezone
interval every_s (≥ 60) Every N seconds after the previous fire
once at (local ISO time) Once
business_day nth (1–23, or -1 = last), time The nth Monday–Friday of each month that isn’t in skip_calendars
  • Cron is evaluated in local wall-clock time, so 0 6 * * * in Europe/Dublin runs at 06:00 local on both sides of a daylight-saving change.
  • skip_calendars: never on those dates (and they aren’t business days). only_calendars: only on those dates (e.g. a month-end calendar).
  • Activation checks that the pipeline and calendars exist.

The scheduler runs in the API. Every tick (FLUX_SCHEDULER_TICK_S, 10 s) it refreshes due calendars, then for each active, enabled schedule:

  1. A new or changed active version computes its next time from now.
  2. When the next time has passed, it fires: a firings row keyed by schedule + scheduled time (so a time fires once, even if a tick is retried) and a queued run with trigger: "schedule" and the scheduled time.
  3. The next time is computed from now.

Downtime. A time missed by more than 5 minutes follows catch_up: once runs one catch-up run (not one per missed time), skip runs nothing. Either way the schedule continues from the next future time.

One scheduler. Each API process tries to take a Postgres advisory lock on a dedicated connection; only the holder schedules. If it dies, the lock is released and another process takes over on its next tick.

Kind trigger (editor):

{"pipeline": "refresh-dashboards",
"enabled": true,
"on": "flux.run.status",
"match": {"status": "succeeded", "pipeline": ["load-orders", "load-customers"]},
"cooldown_s": 300,
"skip_calendars": [], "timezone": "UTC"}
  • on is an event type (design 08): flux.run.status, flux.run.node, flux.dataset.committed, flux.forge.published/revoked, flux.trigger.fired, or flux.external.<name>.
  • match compares event data fields (dotted paths) for equality; a list means any of. The orchestrator’s run status events carry pipeline, version and trigger.
  • cooldown_s: after a trigger starts a run, further matches within the cooldown are ignored.
  • A flux.run.status rule must match another pipeline’s runs (match.pipeline), so a pipeline can’t re-trigger itself forever. Chains across pipelines are allowed.

Evaluation. The event indexer evaluates active rules for every indexed event, in the same database transaction that stores the event. The firing is keyed by rule + event id, so a redelivered event never starts a second run. Rules are cached for 3 seconds, so a new rule applies within seconds.

External events. POST /api/events/external/{name} (editor) publishes flux.external.<name> with the JSON body as data (at most 16 KB), for other systems to start pipelines, for example from a webhook. They’re kept 30 days in the FLUX_EXTERNAL stream.

Every firing is recorded (GET /api/firings?kind=&key=) with the run it started, or why it didn’t (for example: the pipeline has no active version). The firings table doubles as an outbox: the scheduler publishes flux.trigger.<key>.fired for each firing and marks it published, so the event is never lost if NATS is briefly unavailable.

Endpoint
/api/config/{schedule,trigger,calendar}/… Definitions, versions, activation, rollback
POST /api/schedules/preview Next fire times of a draft schedule, calendars applied
GET /api/schedules/state Next and last fire per schedule
GET /api/calendars/{key}/dates, POST …/refresh (admin) Dates, refresh status
GET /api/firings Recent firings
POST /api/events/external/{name} External event

The app’s Automation page manages all three, with a live preview of the next runs.

Fire times (cron across DST, calendars, business days, intervals, once), ICS parsing and refresh with failure handling, admin-only calendars, the scheduler firing once per time and handling downtime, schedule activation checks, trigger matching with lists, redelivery, cooldown and loop protection, and, against live NATS, an external event firing a rule and the firing event arriving through the outbox.

  • File-arrival triggers for drop folders (a polling sensor that emits an event).
  • Per-schedule run parameters once pipelines take parameters.

See the architecture overview.