]> git.giacomolli.uk - onechat/commit
Keep the schedules in a file
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 00:24:44 +0000 (21:24 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 00:24:44 +0000 (21:24 -0300)
commit396af2e18eb02d4ec1e35edbc62f01e84bae2b46
treea2de3d711318faaf936d7c81a6e40ce13b57e873
parent03ef0cf2e8b23ae3954a89883bde4bb557b9ccee
Keep the schedules in a file

The agent gets schedules: a task with one local time or a cron
expression. agent/schedules.json holds them, and each set and remove
writes it whole with mode 0600 before it returns, so a schedule survives
a restart. The file keeps the last ID, so that an ID is never used
again. A mutex protects the schedules, because the tools change them
from a turn while the runs read them.

A one-time time is a local wall time after now. A time in the hour that
the clock repeats is its first occurrence, as in cron. The cron
expressions are checked at a set and at the start.

A run ends with Done: a one-time schedule goes, and a repeating one gets
the next time after now, so a repeating schedule that missed several
times while the daemon was stopped runs once. The message of a run names
the schedule, gives its time and the task, says when the run is more
than one minute late, and ends with the line about the empty reply, as a
WhatsApp batch does.

Issue: 60e4e4f
schedule.go [new file with mode: 0644]
schedule_test.go [new file with mode: 0644]