Download start.sh from dss11/vscds: direct link, hf CLI and curl.
- Browser
- Download file 2.95 kB
-
https://huggingface.co/spaces/dss11/vscds/resolve/main/start.sh
- Command line
-
hf download hf://spaces/dss11/vscds/start.sh
-
curl -L -o start.sh https://huggingface.co/spaces/dss11/vscds/resolve/main/start.sh
2.95 kB
| # 调试信息 - 非常重要! | |
| echo "===== Debug Info =====" | |
| echo "User: $(whoami)" | |
| echo "Home: $HOME" | |
| echo "UID: $(id -u)" | |
| echo "GID: $(id -g)" | |
| echo "Working dir: $(pwd)" | |
| echo "Files in $HOME:" | |
| ls -la $HOME | |
| echo "Files in $HOME/.config:" | |
| ls -la $HOME/.config || echo "No .config directory" | |
| echo "Files in $HOME/.local/share:" | |
| ls -la $HOME/.local/share || echo "No .local/share directory" | |
| echo "======================" | |
| # 1. 修复 Nginx 权限问题 | |
| cat > /tmp/nginx.conf <<EOF | |
| worker_processes auto; | |
| pid /tmp/nginx.pid; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| client_body_temp_path /tmp/client_body; | |
| fastcgi_temp_path /tmp/fastcgi_temp; | |
| proxy_temp_path /tmp/proxy_temp; | |
| scgi_temp_path /tmp/scgi_temp; | |
| uwsgi_temp_path /tmp/uwsgi_temp; | |
| server { | |
| listen 7860; | |
| root /var/www/html; | |
| index index.html; | |
| } | |
| } | |
| EOF | |
| # 启动 Nginx | |
| echo "Starting Nginx..." | |
| nginx -c /tmp/nginx.conf -g "daemon off;" & | |
| # 2. 修复 code-server 权限问题 | |
| # 确保目录存在 | |
| mkdir -p $HOME/.config/code-server | |
| mkdir -p $HOME/.local/share/code-server | |
| mkdir -p $HOME/.local/share/code-server/extensions | |
| # 设置 VS Code 密码 | |
| PASSWORD=${VSCODE_PASSWORD:-"your_strong_password"} | |
| export PASSWORD | |
| # 启动 VS Code (添加详细日志) | |
| echo "Starting code-server with extra logging..." | |
| code-server \ | |
| --bind-addr 0.0.0.0:8080 \ | |
| --auth password \ | |
| --disable-telemetry \ | |
| --disable-update-check \ | |
| --log debug \ | |
| --verbose \ | |
| --config $HOME/.config/code-server/config.yaml \ | |
| --user-data-dir $HOME/.local/share/code-server \ | |
| --extensions-dir $HOME/.local/share/code-server/extensions 2>&1 | tee /tmp/code-server.log & | |
| # 等待 code-server 启动 | |
| echo "Waiting for code-server to start..." | |
| sleep 5 | |
| # 检查 code-server 是否在运行 | |
| if ! pgrep -f "code-server" > /dev/null; then | |
| echo "ERROR: code-server failed to start!" | |
| echo "--- code-server logs ---" | |
| cat /tmp/code-server.log || echo "No logs available" | |
| echo "-----------------------" | |
| exit 1 | |
| fi | |
| # 检查端口监听 | |
| echo "Checking network status:" | |
| echo "Processes:" | |
| ps aux | |
| echo "Port 8080:" | |
| ss -tulpn | grep 8080 || echo "No process listening on 8080" | |
| # 3. 启动 Cloudflare Tunnel | |
| echo "Starting Cloudflare Tunnel..." | |
| cloudflared tunnel run --token $TUNNEL_TOKEN 2>&1 | tee /tmp/cloudflared.log & | |
| # 4. 添加保活机制(防止容器退出) | |
| echo "All services started. Waiting and pinging services periodically..." | |
| while true; do | |
| # 每30秒检查一次服务状态 | |
| echo "Service status:" | |
| echo "- Nginx: $(pgrep nginx | wc -l) processes" | |
| echo "- code-server: $(pgrep -f "code-server" | wc -l) processes" | |
| echo "- cloudflared: $(pgrep cloudflared | wc -l) processes" | |
| # 访问本地服务保持活跃 | |
| curl -s http://localhost:7860 > /dev/null || echo "Nginx ping failed" | |
| curl -s http://localhost:8080 > /dev/null || echo "code-server ping failed" | |
| sleep 30 | |
| done |