59 lines
1.2 KiB
Markdown
59 lines
1.2 KiB
Markdown
# Backend
|
|
|
|
Django REST Framework backend for the minimal queue.
|
|
|
|
The backend owns two models:
|
|
|
|
- `Job`
|
|
- `JobEvent`
|
|
|
|
Workers do not call public claim endpoints. The worker command imports the same service functions that API views use for creation, retry, stats, and event reads.
|
|
|
|
## API
|
|
|
|
```http
|
|
GET /api/health/
|
|
POST /api/jobs/
|
|
GET /api/jobs/
|
|
GET /api/jobs/{id}/
|
|
GET /api/jobs/{id}/events/
|
|
GET /api/job-events/?after_id=123&limit=100
|
|
GET /api/jobs/stats/
|
|
POST /api/jobs/{id}/retry/
|
|
```
|
|
|
|
## Admin
|
|
|
|
The project uses `django-unfold` for the Django admin UI.
|
|
|
|
```text
|
|
http://localhost:8000/admin/
|
|
```
|
|
|
|
Create a user:
|
|
|
|
```powershell
|
|
docker compose exec backend python manage.py createsuperuser
|
|
```
|
|
|
|
## Worker
|
|
|
|
```powershell
|
|
python manage.py run_job_workers
|
|
```
|
|
|
|
Worker settings come from environment variables:
|
|
|
|
```env
|
|
JOB_WORKER_THREADS=4
|
|
JOB_WORKER_POLL_INTERVAL_MS=500
|
|
JOB_WORKER_LEASE_SECONDS=30
|
|
JOB_WORKER_CLEANUP_INTERVAL_SECONDS=5
|
|
JOB_WORKER_BACKOFF_BASE_SECONDS=5
|
|
JOB_WORKER_BACKOFF_MAX_SECONDS=300
|
|
JOB_WORKER_MAX_ATTEMPTS_DEFAULT=3
|
|
JOB_WORKER_LOG_LEVEL=INFO
|
|
```
|
|
|
|
Use `JOB_WORKER_LOG_LEVEL=DEBUG` to log every worker poll, claim, lease renewal, progress update, retry, failure, and completion in the worker terminal.
|