-
-
Notifications
You must be signed in to change notification settings - Fork 5
Watch Mode
Watch mode runs kei as a long-lived process and repeats the sync cycle at a fixed interval.
[watch]
interval = 3600Then run:
kei syncFor service and Docker deployments, prefer kei service run. If no config sets [watch].interval, service run falls back to once per day, 86400 seconds.
After a download pass, kei sleeps for the configured number of seconds, then starts another pass. It repeats until stopped.
Each cycle checks for changes using stored CloudKit sync tokens. If nothing changed, the check usually completes in 1-2 API calls. On the first cycle, or after sync tokens are reset, kei performs a full enumeration.
The minimum interval is 60 seconds. Short intervals risk Apple rate limiting.
Before starting a new cycle after idle sleep, kei reacquires the per-account session lock. If it cannot reacquire the lock, watch mode stops instead of starting another sync without ownership of the account session.
The /changes/database precheck is conservative. If Apple returns an empty complete page, kei may skip that wakeup, but it does not advance the database-level sync token from that empty response.
Ctrl+C, SIGTERM, or SIGHUP during a cycle will:
- Finish in-flight downloads when possible.
- Keep partial
.kei-tmpfiles for resume. - Skip queued downloads.
- Persist state and exit.
A second signal force-exits.
[watch].reconcile_every_n_cycles = N runs a read-only reconcile check every N watch cycles. It catches files deleted from the download directory between syncs. Missing files are marked failed so the next sync re-downloads them.
[watch]
interval = 3600
reconcile_every_n_cycles = 240 or an unset key disables the periodic check.
kei install writes service files that run kei service run. On Linux, kei uses systemd notification support from the generated unit. If you run your own unit, set the durable settings in TOML:
[Service]
Type=notify
ExecStart=/usr/local/bin/kei service run --config /etc/kei/config.toml
Restart=on-failure
WatchdogSec=7200[watch]
interval = 3600
notify_systemd = true
pid_file = "/run/kei.pid"