Claude Code Claude Opus 4.6 commited on
Commit
917f98e
·
1 Parent(s): f855457

Claude Code: Ensure .env is sourced for both uvicorn and worker processes

Browse files

- Create .env from .env.example if missing (prevents split-brain state)
- Always source .env before starting background processes
- Ensures FastAPI app and worker share the same environment context

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. entrypoint.sh +16 -6
entrypoint.sh CHANGED
@@ -23,14 +23,24 @@ echo "=========================================="
23
  # Change to app directory
24
  cd /app
25
 
26
- # Load .env file if it exists (for local development)
27
- if [ -f "/app/.env" ]; then
28
- echo "Loading .env file..."
29
- set -a # Automatically export all variables
30
- source /app/.env
31
- set +a
 
 
 
 
32
  fi
33
 
 
 
 
 
 
 
34
  # Set data directory to dataset mount point
35
  export OPENCLAW_DATA_DIR=/data
36
 
 
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)
39
+ echo "Loading .env file..."
40
+ set -a # Automatically export all variables
41
+ source /app/.env
42
+ set +a
43
+
44
  # Set data directory to dataset mount point
45
  export OPENCLAW_DATA_DIR=/data
46