Skip to content

Commit

Permalink
allow remote debugging again
Browse files Browse the repository at this point in the history
  • Loading branch information
hgross committed Nov 9, 2024
1 parent 410f65c commit 2121598
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ RUN usermod -a -G audio,video,tty chromium
RUN curl -skL https://raw.githubusercontent.com/balena-labs-projects/audio/master/scripts/alsa-bridge/debian-setup.sh| sh
ENV PULSE_SERVER=tcp:audio:4317

# install socat to forard chromiums debug port
RUN install_packages socat

COPY VERSION .

# Start app
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The following environment variables allow configuration of the `browser` block:
|`WINDOW_SIZE`|`x,y`|Detected screen resolution|Sets the browser window size, such as `800,600`. <br/> **Note:** Reverse the dimensions if you also rotate the display to `left` or `right` |
|`WINDOW_POSITION`|`x,y`|`0,0`|Specifies the browser window position on the screen|
|`API_PORT`|port number|5011|Specifies the port number the API runs on|
|`REMOTE_DEBUG_PORT`|port number|35173|Specifies the port number the chrome remote debugger runs on|
|`REMOTE_DEBUG_PORT`|port number|35173|Specifies the port number the chrome remote debugger runs on. The actual port a client (like chrome) might connect to it will be REMOTE_DEBUG_PORT + 1 due to a deprecation of [this chromium feature](https://issues.chromium.org/issues/41487252).|
|`AUTO_REFRESH`|interval|0 (disabled)|Specifies the number of seconds before the page automatically refreshes|

---
Expand Down
9 changes: 9 additions & 0 deletions src/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,13 @@ environment="${environment::-1}"

# launch Chromium and whitelist the enVars so that they pass through to the su session
su -w $environment -c "export DISPLAY=:$DISPLAY_NUM && startx /usr/src/app/startx.sh $CURSOR" - chromium

# forward the chromium remote debugging port from 0.0.0.0 to localhost to deal with the dropped support to listen on all interfaces (https://issues.chromium.org/issues/41487252)
REMOTE_DEBUG_PORT=${REMOTE_DEBUG_PORT:-35173}
REMOTE_DEBUG_FORWARD_PORT=$(($REMOTE_DEBUG_PORT+1))
echo "Forwarding remote debugging port 0.0.0.0:$REMOTE_DEBUG_FORWARD_PORT to (internal) localhost:$REMOTE_DEBUG_PORT"
socat TCP-LISTEN:${REMOTE_DEBUG_FORWARD_PORT},fork,reuseaddr TCP:localhost:${REMOTE_DEBUG_PORT} &

# TODO: We should use REMOTE_DEBUG_PORT as the main env var, and handle the forwarding internally instead of this workaround-convention. The main api to a user should remain REMOTE_DEBUG_PORT

balena-idle

0 comments on commit 2121598

Please sign in to comment.