#!/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