File size: 1,256 Bytes
dcfef50 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/bin/bash
set -e
echo "===== VSCode Server Startup at $(date) ====="
echo "Starting minimal services..."
cd /home/user
# 创建日志目录
mkdir -p /home/user/logs
# 启动nginx
echo "Starting nginx..."
nginx -c /etc/nginx/nginx.conf &
NGINX_PID=$!
echo "Nginx started with PID: $NGINX_PID"
# 等待nginx启动
sleep 2
# 启动code-server
echo "Starting code-server..."
code-server --config /home/user/.config/code-server/config.yaml &
CODE_SERVER_PID=$!
echo "Code-server started with PID: $CODE_SERVER_PID"
# 等待code-server启动
sleep 3
# 启动cloudflare tunnel (如果有token)
if [ ! -z "$TUNNEL_TOKEN" ]; then
echo "Starting Cloudflare Tunnel with token..."
cloudflared tunnel run --token $TUNNEL_TOKEN &
TUNNEL_PID=$!
echo "Cloudflare Tunnel started with PID: $TUNNEL_PID"
else
echo "No TUNNEL_TOKEN provided, starting Quick Tunnel..."
cloudflared tunnel --url http://localhost:7860 &
TUNNEL_PID=$!
echo "Cloudflare Quick Tunnel started with PID: $TUNNEL_PID"
fi
echo "All services started successfully!"
echo "Access URLs:"
echo " - Code-server: http://localhost:7860"
echo " - Nginx: http://localhost:8080"
echo " - VSCode via Nginx: http://localhost:8080/admin-vscode"
# 等待所有进程
wait |