@@ -84,12 +84,127 @@ Database models for storing image information
8484
8585## Management Commands
8686
87- ### ` build_img_queue `
88- Processes pending images in the queue:
87+ ### ` easy_images `
88+
89+ Manages the EasyImage queue with subcommands for building, requeuing, and checking status. This is the primary command for managing image processing.
90+
91+ #### Basic Usage
92+
8993``` bash
90- python manage.py build_img_queue
94+ # Show queue status (default action)
95+ python manage.py easy_images
96+ python manage.py easy_images status
97+
98+ # Build queued images
99+ python manage.py easy_images build
100+
101+ # Requeue failed images
102+ python manage.py easy_images requeue
91103```
92104
105+ #### Subcommands
106+
107+ ##### ` status ` (default)
108+ Shows queue statistics and current state:
109+
110+ ``` bash
111+ python manage.py easy_images status
112+ python manage.py easy_images status --verbose # Show error distribution
113+ ```
114+
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)
120+
121+ ##### ` build `
122+ Processes queued images with intelligent stale detection:
123+
124+ ``` bash
125+ python manage.py easy_images build
126+ python manage.py easy_images build --stale-after 300 # Stale if BUILDING > 5 minutes
127+ python manage.py easy_images build --max-errors 3 # Skip images with > 3 errors
128+ python manage.py easy_images build --verbose # Show detailed progress
129+ ```
130+
131+ Options:
132+ - ` --stale-after <seconds> ` - Images stuck in BUILDING status longer than this are considered stale and reprocessed (default: 600 seconds)
133+ - ` --max-errors <count> ` - Only retry images with at most this many previous errors
134+ - ` --verbose ` - Show detailed progress and error information
135+
136+ ##### ` requeue `
137+ Resets failed images back to QUEUED status for reprocessing:
138+
139+ ``` bash
140+ python manage.py easy_images requeue
141+ python manage.py easy_images requeue --max-errors 5 # Only if ≤ 5 errors
142+ python manage.py easy_images requeue --include-stale # Also requeue stale builds
143+ ```
144+
145+ Options:
146+ - ` --max-errors <count> ` - Only requeue images with at most this many errors
147+ - ` --include-stale ` - Also requeue images stuck in BUILDING status
148+ - ` --stale-after <seconds> ` - With --include-stale, defines stale threshold (default: 600)
149+
150+ #### Image Processing States
151+
152+ - ** Queued** - New images waiting to be processed
153+ - ** Building** - Images currently being processed (auto-detected as stale if too old)
154+ - ** Built** - Successfully processed images
155+ - ** Source Error** - Source file couldn't be accessed
156+ - ** Build Error** - Failed during processing
157+
158+ #### Smart Stale Detection
159+
160+ The command automatically handles crashed or stuck builds by checking the ` status_changed_date ` :
161+ - Images in BUILDING status with recent timestamps are skipped (actually building)
162+ - Images in BUILDING status with old timestamps are treated as stale and reprocessed
163+ - No need for manual ` --force ` flag in most cases
164+
165+ #### Integration Examples
166+
167+ 1 . ** Cron Job** - Regular processing with automatic stale handling:
168+ ``` bash
169+ # Process queue every 5 minutes
170+ * /5 * * * * /path/to/python /path/to/manage.py easy_images build
171+ ```
172+
173+ 2 . ** Error Recovery Workflow** :
174+ ``` bash
175+ # Check current status
176+ python manage.py easy_images
177+
178+ # Requeue failed images with < 3 errors
179+ python manage.py easy_images requeue --max-errors 3
180+
181+ # Process the requeued images
182+ python manage.py easy_images build
183+ ```
184+
185+ 3 . ** Monitoring Script** :
186+ ``` bash
187+ # Get detailed status for monitoring
188+ python manage.py easy_images status --verbose
189+ ```
190+
191+ ### ` build_img_queue ` (Deprecated)
192+
193+ ** ⚠️ Deprecated:** This command is maintained for backwards compatibility. Please use ` easy_images build ` instead.
194+
195+ ``` bash
196+ # Old command (deprecated)
197+ python manage.py build_img_queue --retry 3
198+
199+ # New equivalent
200+ python manage.py easy_images build --max-errors 3
201+ ```
202+
203+ The old command will continue to work but displays a deprecation warning. It maps to the new command with these defaults:
204+ - ` --retry ` → ` --max-errors `
205+ - Stale detection enabled with 600 second threshold
206+ - All other behavior remains the same
207+
93208## Template Tags
94209
95210### ` easy_images `
0 commit comments