fix(gh-monitor): replace OpenClaw cron with launchd — zero polling token cost
This commit is contained in:
@@ -140,24 +140,49 @@ Function:
|
||||
|
||||
Entry point: `if __name__ == "__main__": main()`
|
||||
|
||||
### STEP 10 — OpenClaw cron job
|
||||
### STEP 10 — macOS LaunchAgent
|
||||
|
||||
Register via OpenClaw cron API:
|
||||
```json
|
||||
{
|
||||
"name": "gh-monitor",
|
||||
"schedule": { "kind": "every", "everyMs": 300000 },
|
||||
"payload": {
|
||||
"kind": "systemEvent",
|
||||
"text": "Run GitHub PR monitor: cd ~/Projects/hans-tools/gh-monitor && python3 poll.py"
|
||||
},
|
||||
"sessionTarget": "main"
|
||||
}
|
||||
Create `~/Library/LaunchAgents/com.hans.gh-monitor.plist`:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.hans.gh-monitor</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/bin/python3</string>
|
||||
<string>/Users/hansheinemann/Projects/hans-tools/gh-monitor/poll.py</string>
|
||||
</array>
|
||||
<key>StartInterval</key>
|
||||
<integer>300</integer>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/Users/hansheinemann/Projects/hans-tools/gh-monitor/state/stdout.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/Users/hansheinemann/Projects/hans-tools/gh-monitor/state/stderr.log</string>
|
||||
<key>RunAtLoad</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
Note: this is a systemEvent (not agentTurn) so it injects into the main session
|
||||
and Hans handles it inline. If this proves noisy, switch to agentTurn in isolated
|
||||
session.
|
||||
Load with:
|
||||
```bash
|
||||
launchctl load ~/Library/LaunchAgents/com.hans.gh-monitor.plist
|
||||
```
|
||||
|
||||
Pause/resume:
|
||||
```bash
|
||||
launchctl unload ~/Library/LaunchAgents/com.hans.gh-monitor.plist
|
||||
launchctl load ~/Library/LaunchAgents/com.hans.gh-monitor.plist
|
||||
```
|
||||
|
||||
**Token cost:** Zero during polling. The main session is only woken when
|
||||
`poll.py` calls `openclaw system event` — i.e. only when real PR activity
|
||||
is detected.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -115,16 +115,16 @@ intervals across a handful of repos, this is nowhere near the limit.
|
||||
|
||||
---
|
||||
|
||||
## Cron Schedule
|
||||
## Schedule
|
||||
|
||||
Every 5 minutes via OpenClaw cron:
|
||||
```
|
||||
{ "kind": "every", "everyMs": 300000 }
|
||||
```
|
||||
Every 5 minutes via macOS `launchd` (LaunchAgent plist). `poll.py` runs as a
|
||||
plain shell process — no agent session, no tokens consumed during polling.
|
||||
|
||||
Payload: systemEvent → injects wake text into main session.
|
||||
The main session is only woken when `poll.py` finds new activity and calls
|
||||
`openclaw system event`. On a quiet repo this costs zero tokens most of the day.
|
||||
|
||||
Can be paused/resumed via OpenClaw cron management without touching the code.
|
||||
The LaunchAgent can be unloaded/loaded via `launchctl` to pause/resume polling
|
||||
without touching the code.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user