Integrate per-user browser runtimes into subagent API
This commit is contained in:
parent
952b2e7d17
commit
280247e1e5
11 changed files with 777 additions and 21 deletions
|
|
@ -7,10 +7,11 @@ XVFB_LOG="/tmp/xvfb.log"
|
|||
|
||||
VNC_PORT="${VNC_PORT:-5900}"
|
||||
NOVNC_PORT="${NOVNC_PORT:-6080}"
|
||||
CHROME_LOCAL_DEBUG_PORT="${CHROME_LOCAL_DEBUG_PORT:-9223}"
|
||||
CHROME_PUBLIC_DEBUG_PORT="${CHROME_PUBLIC_DEBUG_PORT:-9222}"
|
||||
CHROME_LOCAL_DEBUG_PORT="${CHROME_LOCAL_DEBUG_PORT:-${BROWSER_CHROME_DEBUG_PORT:-9223}}"
|
||||
CHROME_PUBLIC_DEBUG_PORT="${CHROME_PUBLIC_DEBUG_PORT:-${BROWSER_CDP_PROXY_PORT:-9222}}"
|
||||
BROWSER_USE_RPC_PORT="${BROWSER_USE_RPC_PORT:-8787}"
|
||||
CHROME_PROFILE_DIR="${CHROME_PROFILE_DIR:-/src/browser_data}"
|
||||
CHROME_PROFILE_DIR="${CHROME_PROFILE_DIR:-${BROWSER_DATA_DIR:-/src/browser_data}}"
|
||||
BROWSER_ENABLE_UI="${BROWSER_ENABLE_UI:-true}"
|
||||
|
||||
MAX_RESTARTS="${MAX_RESTARTS:-10}"
|
||||
RESTART_WINDOW_SEC="${RESTART_WINDOW_SEC:-60}"
|
||||
|
|
@ -116,19 +117,23 @@ if ! wait_for_x_display 15; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
start_bg fluxbox
|
||||
start_bg x11vnc -display "$DISPLAY" -rfbport "$VNC_PORT" -nopw -listen 0.0.0.0 -xkb -forever -shared
|
||||
start_bg websockify --web=/usr/share/novnc/ "$NOVNC_PORT" "localhost:${VNC_PORT}"
|
||||
if [ "$BROWSER_ENABLE_UI" != "false" ]; then
|
||||
start_bg fluxbox
|
||||
start_bg x11vnc -display "$DISPLAY" -rfbport "$VNC_PORT" -nopw -listen 0.0.0.0 -xkb -forever -shared
|
||||
start_bg websockify --web=/usr/share/novnc/ "$NOVNC_PORT" "localhost:${VNC_PORT}"
|
||||
fi
|
||||
start_bg socat "TCP-LISTEN:${CHROME_PUBLIC_DEBUG_PORT},fork,reuseaddr" "TCP:127.0.0.1:${CHROME_LOCAL_DEBUG_PORT}"
|
||||
start_bg python3 -u /src/browser_use_runner.py
|
||||
|
||||
if ! wait_for_port 127.0.0.1 "$VNC_PORT" 20; then
|
||||
log "fatal: x11vnc did not open port ${VNC_PORT}"
|
||||
exit 1
|
||||
fi
|
||||
if ! wait_for_port 127.0.0.1 "$NOVNC_PORT" 20; then
|
||||
log "fatal: websockify did not open port ${NOVNC_PORT}"
|
||||
exit 1
|
||||
if [ "$BROWSER_ENABLE_UI" != "false" ]; then
|
||||
if ! wait_for_port 127.0.0.1 "$VNC_PORT" 20; then
|
||||
log "fatal: x11vnc did not open port ${VNC_PORT}"
|
||||
exit 1
|
||||
fi
|
||||
if ! wait_for_port 127.0.0.1 "$NOVNC_PORT" 20; then
|
||||
log "fatal: websockify did not open port ${NOVNC_PORT}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if ! wait_for_port 127.0.0.1 "$BROWSER_USE_RPC_PORT" 20; then
|
||||
log "fatal: browser-use RPC did not open port ${BROWSER_USE_RPC_PORT}"
|
||||
|
|
@ -194,4 +199,3 @@ while true; do
|
|||
unset CHROME_EXIT
|
||||
unset CHROME_PID
|
||||
done
|
||||
|
||||
|
|
|
|||
46
browser_env/nginx.browser-view.conf
Normal file
46
browser_env/nginx.browser-view.conf
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
events {}
|
||||
|
||||
http {
|
||||
resolver 127.0.0.11 ipv6=off;
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
location = / {
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "Browser view proxy is running.\n";
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://browser:6080;
|
||||
}
|
||||
|
||||
location ~ ^/view/(?<owner>[a-f0-9]{16})$ {
|
||||
return 302 /view/$owner/vnc.html?path=view/$owner/websockify;
|
||||
}
|
||||
|
||||
location ~ ^/view/(?<owner>[a-f0-9]{16})/(?<rest>.*)$ {
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://browser-use-browser-$owner:6080/$rest$is_args$args;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue