← 所有消息

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.

我们使用必要的cookie来使该网站正常工作。在您的许可下,我们还使用分析工具来改善网站。