← Alle berichten

One tick a minute, and the app says what runs

Scheduling in Phlo lost its last configuration argument this week. The daemon now ticks every served app once a minute, and what actually runs is declared by the app itself.

It took three steps to get there. The daemon shipped with a schedule config: an array of {host, target, every} entries, meant to get tasks::run and fleet::poll off the system crontab. That worked, but the same information now lived in two places, so the array shrank to a list of apps for which tasks::run fires every minute, with the schedules moving into the app. Two days later that list went too. Every app the daemon serves gets the tick, and an app without a tasks resource is skipped after its first one.

What is left is one declaration in the app:

prop tasks => arr(
    invoices: arr(target: 'invoice::send', daily: '06:00'),
    cleanup:  arr(target: 'temp::purge', every: 900),
)

The tasks resource matches every, daily and weekly against the clock, takes a lock per task so a slow run cannot overlap itself, and records the last run. No cron syntax in your app, no external scheduler, and nothing to update on the server when a task is added.

If you are not running the daemon, a single system cron entry per app calling tasks::run does the same thing.

Engine 1.0.1. See Tasks and the Daemon.

We gebruiken essentiële cookies om deze site te laten werken. Met uw toestemming gebruiken we ook analytics om de site te verbeteren.