askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
scheduler.py · 1.7 KB · 39 lines
| 1 | """scheduler -- the daemon's task board. |
| 2 | |
| 3 | object_daemon.process_scheduler reads `task_*` keys out of THIS object's |
| 4 | state on every poll. Each value is JSON: |
| 5 | |
| 6 | {"id", "object_id", "method", "payload", |
| 7 | "schedule", "type": "cron"|"onetime", "status": "active"|"paused"} |
| 8 | |
| 9 | The daemon stamps next_run/last_run/run_count back onto the same key, and |
| 10 | records every execution as a scheduler_runs row (system-dashboard) so a |
| 11 | run's outcome is queryable rather than buried in a log. |
| 12 | |
| 13 | The object is deliberately inert: scheduling is DATA in its state, and the |
| 14 | contract lives in object_daemon.process_scheduler, not here. It ships in a |
| 15 | package rather than being hand-placed on a server because a trigger object |
| 16 | that exists only on one box is a scheduler that dies silently the next |
| 17 | time that box is rebuilt. |
| 18 | |
| 19 | The same argument applies to the tasks themselves, so DO NOT hand-write |
| 20 | rows here. A package declares its recurring passes in its manifest's |
| 21 | `schedules` section and the installer writes them onto this board (see |
| 22 | docs/package-authoring.md); a schedule and the object it calls then travel |
| 23 | together, survive a rebuild, and are reviewable as code. An install |
| 24 | preserves run history and never un-pauses a task an operator stopped, so |
| 25 | declaring one is safe to repeat. Hand-entered tasks still work -- and are |
| 26 | adopted rather than duplicated when a package later declares the same id -- |
| 27 | but they are exactly the invisible state this whole board was meant to |
| 28 | stop being. |
| 29 | """ |
| 30 | |
| 31 | |
| 32 | def GET(request): |
| 33 | return {"ok": True, |
| 34 | "note": "task_* entries in this object's state drive " |
| 35 | "object_daemon.process_scheduler; see /scheduler for the board"} |
| 36 | |
| 37 | |
| 38 | def POST(request): |
| 39 | return {"ok": True} |