schedule/README.md

57 lines
1.2 KiB
Markdown
Raw Normal View History

# 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 name
- `cron` - Cron expression (e.g., `0 9 * * *`)
- `instruction` - What to tell the reason service
- `enabled` - Active flag
## Running
```bash
# 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 minutes
- `0 0 * * 0` - Weekly on Sunday midnight
## Dependencies
- FastAPI
- APScheduler (cron scheduling)
- httpx (to call reason service)