mirror of
https://github.com/tiennm99/claude-code-routine-trigger-worker.git
synced 2026-05-13 22:57:57 +00:00
feat(cron): expand to 20 fires/day, packed into 5 expressions
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
- Cloudflare Workers `scheduled` handler that POSTs to the Claude Code routine `/fire` endpoint.
|
||||
- Default 5×daily cron at UTC+7 (00:07 / 05:13 / 10:19 / 15:23 / 20:37) — scattered minutes for shared-infra hygiene.
|
||||
- Default 20×daily cron at UTC+7 — 00:00 once, then hourly 05-09 / 10-14 / 15-19 / 20-23 with stepped minute offsets (:01-:04). Packed into 5 cron expressions to fit the CF free-tier limit.
|
||||
- Token-substitution template with `{ISO}`, `{LocalTime}`, `{Cron}` (default: `Scheduled trigger at {LocalTime}`).
|
||||
- IANA timezone support via `TZ` env var (default: `UTC`).
|
||||
- Structured JSON logs for fire success / non-2xx / network failure.
|
||||
|
||||
@@ -60,9 +60,11 @@ Edit `wrangler.toml` `[triggers].crons` — Cloudflare requires literal cron exp
|
||||
```toml
|
||||
[triggers]
|
||||
crons = [
|
||||
"7 17 * * *", # 00:07 UTC+7
|
||||
"13 22 * * *", # 05:13 UTC+7
|
||||
# add / remove / edit these lines as needed
|
||||
"0 17 * * *", # 00:00 UTC+7 (17:00 UTC prev day)
|
||||
"1 22,23,0,1,2 * * *", # 05:01-09:01 UTC+7
|
||||
"2 3-7 * * *", # 10:02-14:02 UTC+7
|
||||
"3 8-12 * * *", # 15:03-19:03 UTC+7
|
||||
"4 13-16 * * *", # 20:04-23:04 UTC+7
|
||||
]
|
||||
```
|
||||
|
||||
@@ -71,8 +73,8 @@ Then redeploy: `npx wrangler deploy`.
|
||||
Tips:
|
||||
- Cron runs in **UTC**. Convert your local time: `UTC = local − offset` (e.g. 09:00 UTC+7 → 02:00 UTC → `0 2 * * *`).
|
||||
- Validate expressions at <https://crontab.guru/>.
|
||||
- **Free tier limit:** 5 cron expressions per worker. Default config uses all 5. To run more schedules, deploy another worker.
|
||||
- Scattering minutes (e.g. `7`, `13`, `19`, `23`, `37`) is good hygiene on shared infrastructure even though CF cron is more reliable than GitHub.
|
||||
- **Free tier limit:** 5 cron expressions per worker. Default config uses all 5. Use comma lists (`1 22,23,0,1,2 * * *`) and ranges (`2 3-7 * * *`) to fit more fires per row.
|
||||
- Standard 5-field syntax — supports `*`, `,`, `-`, `/`. Use minute offsets (`:01`, `:02`, …) instead of `:00` to avoid top-of-hour contention on shared infra.
|
||||
|
||||
## Templates
|
||||
|
||||
|
||||
+13
-8
@@ -11,17 +11,22 @@ TZ = "Asia/Ho_Chi_Minh"
|
||||
|
||||
# Cron triggers fire from this list. CF Workers requires literal cron
|
||||
# expressions here — they cannot be loaded from env vars or secrets.
|
||||
# Default schedule mirrors the sibling repos: 5x daily at UTC+7
|
||||
# 00:07 / 05:13 / 10:19 / 15:23 / 20:37 — minutes scattered to avoid
|
||||
# top-of-hour contention (good hygiene; CF cron is more reliable than GH).
|
||||
# Schedule (Asia/Ho_Chi_Minh, UTC+7) — 20 fires/day, packed into 5 expressions:
|
||||
# 00:00 — once at local midnight
|
||||
# 05:01-09:01 — every hour, minute 01
|
||||
# 10:02-14:02 — every hour, minute 02
|
||||
# 15:03-19:03 — every hour, minute 03
|
||||
# 20:04-23:04 — every hour, minute 04
|
||||
# Crons evaluate in UTC, so each row is offset by -7 hours; the 05-09 row
|
||||
# wraps midnight UTC so it uses a comma list rather than a range.
|
||||
# Free tier allows up to 5 cron expressions per worker — at limit.
|
||||
[triggers]
|
||||
crons = [
|
||||
"7 17 * * *",
|
||||
"13 22 * * *",
|
||||
"19 3 * * *",
|
||||
"23 8 * * *",
|
||||
"37 13 * * *",
|
||||
"0 17 * * *", # 00:00 UTC+7 (17:00 UTC prev day)
|
||||
"1 22,23,0,1,2 * * *", # 05:01-09:01 UTC+7
|
||||
"2 3-7 * * *", # 10:02-14:02 UTC+7
|
||||
"3 8-12 * * *", # 15:03-19:03 UTC+7
|
||||
"4 13-16 * * *", # 20:04-23:04 UTC+7
|
||||
]
|
||||
|
||||
# Built-in observability (free tier supports basic logs).
|
||||
|
||||
Reference in New Issue
Block a user