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 &