Crons and wakes
A #[tool(cron)] tool runs on a schedule set in crab.toml, and a call can schedule one later call of a tool, a wake.
Crons
- A
#[tool(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.
crab cron ls <service>lists each cron tool with its schedule, when it is next due, its failures and its last run.
Schedules in crab.toml
[crons]
refresh = "*/5 * * * *"- The build embeds
[crons]in the image. Deploying applies those schedules, including when deploying an existing template. - A cron tool left out has no schedule. Omitting
[crons]stops all static schedules on redeploy. Change the manifest and redeploy to change a schedule.
Runs
- After each run, the tool is scheduled for its next time.
- A failed run is counted among its 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, service, tool, args), delay in milliseconds.
berm_lang::after(300_000, "weather", "poll", "{}")?;- A service has at most one pending wake. Scheduling another replaces it.
- An empty target service (
"") schedules a tool on the current deployment, regardless of its name. - The target is a tool of the service itself, or a public tool of another service of the same account.
- A
#[tool(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.
crab wakes <service>lists pending wakes, soonest first.
While the account is refused
While the account's calls are refused for being past its plan, crons and wakes wait, and crab cron ls and crab wakes say they are held. What came due runs once the account is admitted again.