From 665ff8b1f3451d6c13e437e4028cec85c9baf971 Mon Sep 17 00:00:00 2001 From: jjbrunton Date: Fri, 22 May 2026 21:04:28 +0100 Subject: [PATCH] Clear stale X display lock before starting Xvfb A bot crash leaves /tmp/.X99-lock behind; the next container start hits "Server is already active for display 99" and the entrypoint previously fell through with only a warning, so Chromium then died with "Missing X server or $DISPLAY" in a tight crash loop. Remove the stale lock up-front and fail hard if Xvfb still won't come up, so the failure mode is "container won't start" rather than "bot crashes forever". Co-Authored-By: Claude Opus 4.7 --- docker/entrypoint.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index bac874c..96aa255 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -25,22 +25,30 @@ if [ ! -e "${NOVNC_WEB_DIR}/index.html" ] && [ -e "${NOVNC_WEB_DIR}/vnc.html" ]; ln -sf vnc.html "${NOVNC_WEB_DIR}/index.html" fi +# Clear any stale lock from a prior unclean exit — otherwise Xvfb refuses +# to bind to the display and the bot starts up with no X server. +rm -f "/tmp/.X${DISPLAY_NUM}-lock" "/tmp/.X11-unix/X${DISPLAY_NUM}" 2>/dev/null || true + echo "[entrypoint] starting Xvfb on ${DISPLAY} (${GEOMETRY})" Xvfb "${DISPLAY}" -screen 0 "${GEOMETRY}" -ac +extension RANDR & XVFB_PID=$! # Give Xvfb a moment to come up. Requires x11-utils (xdpyinfo). +XVFB_READY=0 for i in $(seq 1 50); do if xdpyinfo -display "${DISPLAY}" >/dev/null 2>&1; then echo "[entrypoint] Xvfb is ready after ${i} checks" + XVFB_READY=1 break fi sleep 0.2 - if [ "${i}" = "50" ]; then - echo "[entrypoint] WARNING: Xvfb did not respond after 10s" >&2 - fi done +if [ "${XVFB_READY}" != "1" ]; then + echo "[entrypoint] FATAL: Xvfb did not respond after 10s — refusing to launch bot without a display" >&2 + exit 1 +fi + # Minimal window manager so dialogs and tabs aren't stuck behind the root window. if command -v fluxbox >/dev/null 2>&1; then fluxbox >/dev/null 2>&1 &