Community Dashboard

Crons and wakes

A #[cron] tool runs on a schedule set in berm.toml or by an owner, and a call can schedule one later call of a tool, a wake.

Crons

  • A #[cron] tool takes no arguments and cannot be public.
  • Its schedule is a 5-field cron expression in UTC: minute, hour, day of month, month, day of week. The finest schedule runs once a minute.
  • An owner sets a schedule with PUT /services/{owner}/{name}/tools/{tool}/cron and {"cron": "*/5 * * * *"}. {"cron": null} stops it.
  • GET /services/{owner}/{name}/crons lists each cron tool with its schedule, when it is next due, its failures and its last run.

Schedules in berm.toml

[crons]
refresh = "*/5 * * * *"
  • A deploy without [crons] leaves every schedule as it is.
  • A deploy with [crons] sets every cron tool's schedule, and a cron tool it leaves out stops.
  • A deploy that would undo a schedule an owner set since the last deploy is refused unless forced. See Deploying.

Runs

  • After each run, the tool is scheduled for its next time.
  • A failed run is counted in failures and is not retried before its next time.
  • Runs missed while the tool could not run are not replayed. It runs once.

Wakes

A call schedules a wake with berm_lang::after(delay, program, tool, args), delay in milliseconds.

berm_lang::after(300_000, "weather", "poll", "{}")?;
  • A service has at most one pending wake. Scheduling another replaces it.
  • The target is a tool of the service itself, or a public tool of another service of the same account.
  • A #[query] tool cannot schedule a wake.
  • Scheduling a wake counts as one row written.
  • A wake runs with no caller, and a failed wake is retried every 60 seconds.
  • GET /services/{owner}/{name}/wakes lists pending wakes, soonest first.

While calls answer 402

While the account's calls answer 402 (see Plans), crons and wakes wait, and /crons and /wakes answer "held": true. What came due runs once the account is admitted again.