fix(start): allow skipping collectstatic via DISABLE_COLLECTSTATIC env var#1237
fix(start): allow skipping collectstatic via DISABLE_COLLECTSTATIC env var#1237
Conversation
…v var Deployments that serve static files from an external CDN (e.g. Netlify) do not need Django's `collectstatic` to run on container boot. When the configured `STATICFILES_STORAGE` backend is unreachable, `collectstatic` can hang indefinitely on a network call, blocking gunicorn from starting and causing 502 Bad Gateway responses upstream until the container is killed and recreated. This adds an opt-in env var (`DISABLE_COLLECTSTATIC=1`) that skips the step entirely in `compose/production/django/start`. Default behaviour (running `collectstatic`) is unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
✅ Deploy Preview for antenna-preview canceled.
|
✅ Deploy Preview for antenna-ssec canceled.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 39 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in toggle to the production Django container start script so deployments that don’t need Django static collection (or have an unreachable staticfiles backend) can avoid blocking container boot.
Changes:
- Gate
python /app/manage.py collectstatic --noinputbehindDISABLE_COLLECTSTATIC=1. - Log an explicit “Skipping collectstatic …” message when the skip is enabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Adds an opt-in env var (
DISABLE_COLLECTSTATIC=1) to skipcollectstaticincompose/production/django/start. Default behaviour is unchanged.Why
Deployments that serve static files from an external CDN (e.g. Netlify) do not need Django's
collectstaticto run on container boot. When the configuredSTATICFILES_STORAGEbackend is unreachable,collectstaticcan hang indefinitely on a network call. Because/startrunscollectstaticbeforeexec gunicorn, this blocks gunicorn from ever starting and the container appears "up" but nothing listens on port 5000 — producing 502 Bad Gateway responses upstream until the container is killed and recreated.This was observed in a production deployment after a routine container restart. The container had been running fine for weeks because the previous image had a local modification commenting out the
collectstaticline; that modification was lost on the next image rebuild andcollectstaticran against an unreachable backend, hanging at boot.Behaviour
DISABLE_COLLECTSTATICunset or set to anything other than"1"→ unchanged,collectstaticruns as before.DISABLE_COLLECTSTATIC=1→ printsSkipping collectstatic (DISABLE_COLLECTSTATIC=1)and proceeds straight to gunicorn.Test plan
DISABLE_COLLECTSTATICunset → confirmcollectstaticstill runs (existing behaviour).DISABLE_COLLECTSTATIC=1→ confirm the skip message logs and gunicorn starts.startscripts; local development behaviour unchanged.🤖 Generated with Claude Code