Spaces:
Sleeping
Sleeping
Claude Code commited on
Commit ·
1e3e920
1
Parent(s): 917f98e
Claude Code: Always regenerate .env from .env.example on startup
Browse filesPrevents split-brain state where uvicorn and worker process use different
environment contexts. Previously, .env was only created if missing, which
could cause stale configs when HF secrets change.
Co-Authored-By: Claude Code
- entrypoint.sh +9 -10
entrypoint.sh
CHANGED
|
@@ -23,16 +23,15 @@ echo "=========================================="
|
|
| 23 |
# Change to app directory
|
| 24 |
cd /app
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
# This
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
fi
|
| 36 |
fi
|
| 37 |
|
| 38 |
# Load .env file (for local development - ensures worker and uvicorn share env)
|
|
|
|
| 23 |
# Change to app directory
|
| 24 |
cd /app
|
| 25 |
|
| 26 |
+
# CRITICAL: Always regenerate .env from .env.example before starting services
|
| 27 |
+
# This prevents split-brain state where uvicorn/worker use different env contexts
|
| 28 |
+
# when .env exists but is outdated (e.g., HF secrets changed in Space settings)
|
| 29 |
+
if [ -f "/app/.env.example" ]; then
|
| 30 |
+
echo "Regenerating .env from .env.example (ensures fresh environment context)..."
|
| 31 |
+
cp /app/.env.example /app/.env
|
| 32 |
+
else
|
| 33 |
+
echo "WARNING: .env.example not found, creating empty .env..."
|
| 34 |
+
touch /app/.env
|
|
|
|
| 35 |
fi
|
| 36 |
|
| 37 |
# Load .env file (for local development - ensures worker and uvicorn share env)
|