Claude Code commited on
Commit
1e3e920
·
1 Parent(s): 917f98e

Claude Code: Always regenerate .env from .env.example on startup

Browse files

Prevents 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

Files changed (1) hide show
  1. entrypoint.sh +9 -10
entrypoint.sh CHANGED
@@ -23,16 +23,15 @@ echo "=========================================="
23
  # Change to app directory
24
  cd /app
25
 
26
- # Ensure .env exists (create from .env.example if missing)
27
- # This ensures both uvicorn and worker share the same environment context
28
- if [ ! -f "/app/.env" ]; then
29
- if [ -f "/app/.env.example" ]; then
30
- echo "Creating .env from .env.example..."
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
  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)