abcd118q commited on
Commit
d85f0a5
Β·
verified Β·
1 Parent(s): 66e10ae

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +32 -9
start.sh CHANGED
@@ -51,25 +51,48 @@ git config --global pull.rebase false
51
  [ -n "${HF_TOKEN:-}" ] && \
52
  huggingface-cli login --token "$HF_TOKEN" --add-to-git-credential 2>/dev/null || true
53
 
 
54
  LOG "πŸ’» Starting code-server..."
55
- code-server --config /root/.config/code-server/config.yaml \
56
- --disable-telemetry --disable-update-check "$WORKSPACE" \
57
- >> "$CS_LOGS/code-server.log" 2>&1 &
58
- sleep 2
59
 
 
 
 
 
 
 
 
 
 
 
60
  LOG "🌐 Starting stealth browser server..."
61
- cd /app && python3 browser_server.py \
62
- >> "$CS_LOGS/browser.log" 2>&1 &
63
- sleep 3
 
 
 
 
 
 
 
 
 
 
 
64
 
 
65
  echo ""
66
  echo "╔══════════════════════════════════════════════════════╗"
67
- echo "β•‘ πŸš€ Ready β•‘"
68
  echo "╠══════════════════════════════════════════════════════╣"
69
  echo "β•‘ Editor : https://<space>.hf.space/ β•‘"
70
  echo "β•‘ Browser : https://<space>.hf.space/browser/ β•‘"
71
  echo "β•‘ Password: $PASSWORD"
72
  echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"
73
 
74
- LOG "🌐 Starting nginx..."
75
  exec nginx -g "daemon off;"
 
51
  [ -n "${HF_TOKEN:-}" ] && \
52
  huggingface-cli login --token "$HF_TOKEN" --add-to-git-credential 2>/dev/null || true
53
 
54
+ # ── 1. code-server ───────────────────────────────────────────────
55
  LOG "πŸ’» Starting code-server..."
56
+ code-server \
57
+ --config /root/.config/code-server/config.yaml \
58
+ --disable-telemetry --disable-update-check \
59
+ "$WORKSPACE" >> "$CS_LOGS/code-server.log" 2>&1 &
60
 
61
+ # Wait for code-server to be ready
62
+ LOG "⏳ Waiting for code-server..."
63
+ for i in $(seq 1 30); do
64
+ if curl -sf http://127.0.0.1:8080/ -o /dev/null 2>&1; then
65
+ LOG "βœ… code-server ready (${i}s)"; break
66
+ fi
67
+ sleep 1
68
+ done
69
+
70
+ # ── 2. Browser server ────────────────────────────────────────────
71
  LOG "🌐 Starting stealth browser server..."
72
+ cd /app && python3 browser_server.py >> "$CS_LOGS/browser.log" 2>&1 &
73
+
74
+ # Playwright + Chromium launch takes time β€” wait properly
75
+ LOG "⏳ Waiting for browser server (Chromium init)..."
76
+ for i in $(seq 1 60); do
77
+ if curl -sf http://127.0.0.1:8888/ -o /dev/null 2>&1; then
78
+ LOG "βœ… Browser server ready (${i}s)"; break
79
+ fi
80
+ if [ $i -eq 60 ]; then
81
+ LOG "❌ Browser server failed to start. Last logs:"
82
+ tail -20 "$CS_LOGS/browser.log"
83
+ fi
84
+ sleep 1
85
+ done
86
 
87
+ # ── 3. nginx ─────────────────────────────────────────────────────
88
  echo ""
89
  echo "╔══════════════════════════════════════════════════════╗"
90
+ echo "β•‘ πŸš€ All services ready β•‘"
91
  echo "╠══════════════════════════════════════════════════════╣"
92
  echo "β•‘ Editor : https://<space>.hf.space/ β•‘"
93
  echo "β•‘ Browser : https://<space>.hf.space/browser/ β•‘"
94
  echo "β•‘ Password: $PASSWORD"
95
  echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•"
96
 
97
+ LOG "🌐 Starting nginx on :7860..."
98
  exec nginx -g "daemon off;"