Claude Code commited on
Commit
bad336e
·
1 Parent(s): 6b4f1b8

Claude Code: Simplify entrypoint.sh - remove complex restart loop causing premature exit

Browse files
Files changed (1) hide show
  1. entrypoint.sh +4 -52
entrypoint.sh CHANGED
@@ -1,6 +1,5 @@
1
- #!/bin/bash
2
  # Entrypoint for HuggingClaw - Cain
3
- # Provides explicit logging and auto-restart on crashes
4
 
5
  echo "=========================================="
6
  echo "Cain Starting..."
@@ -18,13 +17,6 @@ if [ ! -f "/app/app.py" ]; then
18
  fi
19
  echo "✓ app.py found"
20
 
21
- # Verify openclaw package
22
- if [ -d "/app/openclaw" ]; then
23
- echo "✓ openclaw directory found"
24
- else
25
- echo "⚠ openclaw directory not found"
26
- fi
27
-
28
  # List key files for debugging
29
  echo ""
30
  echo "Files in /app:"
@@ -32,48 +24,8 @@ ls -la /app/*.py 2>/dev/null || echo " (no .py files in /app root)"
32
 
33
  echo ""
34
  echo "=========================================="
35
- echo "Waiting 3 seconds before starting uvicorn..."
36
- echo "=========================================="
37
- sleep 3
38
  echo "=========================================="
39
- echo "Starting uvicorn with auto-restart on crash..."
40
- echo "=========================================="
41
-
42
- # Auto-restart loop: if uvicorn crashes, wait 2s and restart
43
- while true; do
44
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] Starting uvicorn on 0.0.0.0:${PORT:-7860}..." >&2
45
- uvicorn app:app --host 0.0.0.0 --port "${PORT:-7860}" 2>&1 | tee >(cat >&2) &
46
- UVICORN_PID=$!
47
-
48
- # Wait for uvicorn to start and port to be ready
49
- PORT=${PORT:-7860}
50
- MAX_WAIT=30
51
- WAIT_COUNT=0
52
- while [ $WAIT_COUNT -lt $MAX_WAIT ]; do
53
- if nc -z localhost $PORT 2>/dev/null || curl -s http://localhost:$PORT/health > /dev/null 2>&1; then
54
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] ✓ Port $PORT is ready!" >&2
55
- break
56
- fi
57
- WAIT_COUNT=$((WAIT_COUNT + 1))
58
- sleep 1
59
- done
60
-
61
- if [ $WAIT_COUNT -eq $MAX_WAIT ]; then
62
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] ✗ ERROR: Port $PORT did not become ready after $MAX_WAIT seconds!" >&2
63
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] Startup failure detected. Check logs above for errors." >&2
64
- fi
65
-
66
- # Wait for uvicorn process
67
- wait $UVICORN_PID
68
- EXIT_CODE=$?
69
-
70
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] uvicorn exited with code: $EXIT_CODE"
71
-
72
- if [ $EXIT_CODE -eq 0 ]; then
73
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] Clean exit, not restarting"
74
- break
75
- fi
76
 
77
- echo "[$(date -u +"%Y-%m-%dT%H:%M:%SZ")] Crash detected! Restarting in 2 seconds..."
78
- sleep 2
79
- done
 
1
+ #!/bin/bash -e
2
  # Entrypoint for HuggingClaw - Cain
 
3
 
4
  echo "=========================================="
5
  echo "Cain Starting..."
 
17
  fi
18
  echo "✓ app.py found"
19
 
 
 
 
 
 
 
 
20
  # List key files for debugging
21
  echo ""
22
  echo "Files in /app:"
 
24
 
25
  echo ""
26
  echo "=========================================="
27
+ echo "Starting uvicorn..."
 
 
28
  echo "=========================================="
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ # Run uvicorn directly - keep container running
31
+ exec uvicorn app:app --host 0.0.0.0 --port "${PORT:-7860}"