Skip to content

Commit dbf5e43

Browse files
committed
docs: update status command with formats, health gates, examples
1 parent 9704e9f commit dbf5e43

File tree

1 file changed

+73
-10
lines changed

1 file changed

+73
-10
lines changed

docs/api.md

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,75 @@ python manage.py easy_images requeue
105105
#### Subcommands
106106

107107
##### `status` (default)
108-
Shows queue statistics and current state:
108+
Shows queue statistics and current state. Supports multiple output formats and health gates:
109109

110110
```bash
111+
# Auto format: pretty on TTY, plain otherwise
111112
python manage.py easy_images status
112-
python manage.py easy_images status --verbose # Show error distribution
113+
114+
# Explicit formats
115+
python manage.py easy_images status --format pretty
116+
python manage.py easy_images status --format plain
117+
python manage.py easy_images status --format json
118+
119+
# Options
120+
python manage.py easy_images status --stale-after 600 # Stale BUILDING threshold (seconds)
121+
python manage.py easy_images status --verbose # Show error distribution
122+
python manage.py easy_images status --fail-on-stale # Exit non-zero if stale builds exist
123+
python manage.py easy_images status --fail-on-errors 5 # Exit non-zero if errors > 5
124+
```
125+
126+
Plain/pretty output includes:
127+
- Total source images (distinct storage+name)
128+
- Total generated images
129+
- Total images in queue (unbuilt: queued+building+errors)
130+
- Average generated per source
131+
- Breakdown by status (queued, building with stale count, errors split by type)
132+
- Error count distribution (with `--verbose`)
133+
- Suggestions (commands to remediate)
134+
135+
Example (pretty):
136+
137+
```
138+
Summary: 7 sources | 3 generated (0.43/src) | 5 queued | 2 building (1 stale) | 2 errors (S:1 B:1)
139+
140+
Totals:
141+
Total source images: 7
142+
Total generated images: 3
143+
Total images in queue: 5
144+
Avg generated per source: 0.43
145+
146+
Breakdown:
147+
Queued: 5 █████
148+
Building: 2 ██ (1 stale > 600s)
149+
Errors: 2 ██ (source: 1, build: 1)
150+
151+
Suggestions:
152+
python manage.py easy_images build --stale-after 600
153+
python manage.py easy_images requeue --max-errors 3
113154
```
114155

115-
Output includes:
116-
- Total images in queue
117-
- Breakdown by status (queued, building, errors)
118-
- Detection of stale builds
119-
- Error count distribution (with --verbose)
156+
JSON schema:
157+
158+
```json
159+
{
160+
"counts": {
161+
"sources": 7,
162+
"generated": 3,
163+
"queued": 5,
164+
"building": 2,
165+
"source_errors": 1,
166+
"build_errors": 1
167+
},
168+
"avg_per_source": 0.43,
169+
"stale": { "threshold_seconds": 600, "count": 1 },
170+
"error_dist": [{ "error_count": 1, "count": 2 }],
171+
"suggestions": [
172+
"python manage.py easy_images build --stale-after 600",
173+
"python manage.py easy_images requeue --max-errors 3"
174+
]
175+
}
176+
```
120177

121178
##### `build`
122179
Processes queued images with intelligent stale detection:
@@ -184,8 +241,14 @@ The command automatically handles crashed or stuck builds by checking the `statu
184241

185242
3. **Monitoring Script**:
186243
```bash
187-
# Get detailed status for monitoring
188-
python manage.py easy_images status --verbose
244+
# Pretty output for humans (TTY)
245+
python manage.py easy_images status --stale-after 600 --verbose
246+
247+
# JSON for machines
248+
python manage.py easy_images status --format json --stale-after 600
249+
250+
# Fail CI/monitoring if stale builds or too many errors
251+
python manage.py easy_images status --fail-on-stale --fail-on-errors 0
189252
```
190253

191254
### `build_img_queue` (Deprecated)
@@ -225,4 +288,4 @@ Template tags for rendering processed images:
225288
The template tag supports adding custom HTML attributes to the generated `<img>` element by prefixing them with `img_`. For example:
226289
- `img_class="my-class"` becomes `class="my-class"`
227290
- `img_loading="lazy"` becomes `loading="lazy"`
228-
- `img_data_id="123"` becomes `data-id="123"`
291+
- `img_data_id="123"` becomes `data-id="123"`

0 commit comments

Comments
 (0)