Spaces:
Build error
Build error
| # VNC and Gradio Startup Script | |
| # This script starts VNC server, web bridge, and Gradio interface | |
| set -e | |
| echo "π Starting VNC Desktop Environment..." | |
| # Start VNC server | |
| echo "πΊ Starting VNC server on port $VNC_PORT..." | |
| export VNC_PORT=${VNC_PORT:-5901} | |
| export VNC_PASSWORD=${VNC_PASSWORD:-computer-agent} | |
| # Set VNC display | |
| export DISPLAY=:99 | |
| # Kill any existing VNC servers | |
| pkill -f vnc || true | |
| pkill -f websockify || true | |
| # Start VNC server in background | |
| echo "π§ Starting TigerVNC server..." | |
| vncserver :99 -geometry 1920x1080 -depth 24 -PasswordFile=/root/.vnc/passwd & | |
| VNC_PID=$! | |
| echo "VNC server started with PID: $VNC_PID" | |
| # Wait for VNC server to be ready | |
| sleep 3 | |
| # Start websockify to bridge VNC to web | |
| echo "π Starting Websockify bridge..." | |
| websockify --web /usr/share/novnc 0.0.0.0:$VNC_PORT & | |
| WEBSOCKIFY_PID=$! | |
| echo "Websockify started with PID: $WEBSOCKIFY_PID" | |
| # Start XFCE4 desktop environment | |
| echo "π₯οΈ Starting XFCE4 desktop..." | |
| export XDG_RUNTIME_DIR=/tmp/runtime-root | |
| export QT_X11_NO_MITSHM=1 | |
| # Wait a bit more for VNC to be fully ready | |
| sleep 2 | |
| # Start desktop environment in background | |
| startxfce4 & | |
| DESKTOP_PID=$! | |
| echo "Desktop environment started with PID: $DESKTOP_PID" | |
| # Give desktop environment time to start | |
| sleep 5 | |
| echo "β VNC environment is ready!" | |
| echo "π VNC Port: $VNC_PORT" | |
| echo "π Web Interface: http://localhost:7860" | |
| # Function to cleanup on exit | |
| cleanup() { | |
| echo "π Shutting down services..." | |
| kill $VNC_PID $WEBSOCKIFY_PID $DESKTOP_PID 2>/dev/null || true | |
| pkill -f vnc || true | |
| pkill -f websockify || true | |
| pkill -f startxfce4 || true | |
| exit 0 | |
| } | |
| # Trap cleanup signals | |
| trap cleanup SIGTERM SIGINT | |
| # Start Gradio interface in foreground | |
| echo "π Starting Computer-Using Agent interface..." | |
| python computer_agent.py |