Task scheduler service
- Background scheduler thread (30s interval) - Cron expression parsing with cron crate - File-based JSON storage (compatible with existing data) - HTTP API: CRUD, manual run, history - ~3MB binary vs ~50MB Python Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| src | ||
| .gitignore | ||
| __init__.py | ||
| Cargo.lock | ||
| Cargo.toml | ||
| main.py | ||
| README.md | ||
| scheduler.py | ||
Schedule Service
Task scheduler for Egregore.
Purpose
Cron-like scheduler that triggers AI tasks on a schedule. Wakes the reason service at configured times to perform automated work.
Endpoints
| Endpoint | Method | Description |
|---|---|---|
/schedules |
GET/POST | List or create schedules |
/schedules/{id} |
GET/PATCH/DELETE | Manage a schedule |
/schedules/{id}/run |
POST | Manually trigger a schedule |
/schedules/{id}/history |
GET | View execution history |
/health |
GET | Health check |
Configuration
Schedules stored in ~/data/schedules/.
Each schedule has:
name- Descriptive namecron- Cron expression (e.g.,0 9 * * *)instruction- What to tell the reason serviceenabled- Active flag
Running
# Activate venv
source ~/.venv/bin/activate
# Run directly
python main.py
# Or via systemd
sudo systemctl start schedule
sudo systemctl status schedule
Cron Format
Standard 5-field cron: minute hour day month weekday
Examples:
0 9 * * *- Daily at 9am*/15 * * * *- Every 15 minutes0 0 * * 0- Weekly on Sunday midnight
Dependencies
- FastAPI
- APScheduler (cron scheduling)
- httpx (to call reason service)