From 05fdd15406209056957fe0536474ca11c8927109 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Sun, 16 Aug 2026 14:43:14 -0400 Subject: [PATCH] [FIX] Shelfmark: internal bypasser never starts under the gevent worker (#16495) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Shelfmark: fix internal bypasser under the gevent worker The internal captcha bypasser never worked on this install. Shelfmark is served by gunicorn's GeventWebSocketWorker, and DOCKERMODE controls whether the bypass browser runs in a helper process "isolated from gunicorn/gevent" (upstream's _get_via_subprocess). With DOCKERMODE=false the SeleniumBase CDP browser starts inside the monkey-patched loop, its asyncio websocket never connects, and every bypass dies at "Pure CDP browser startup timed out after 45s" — searches then burn their whole retry budget and surface as "mirrors are blocked". Set DOCKERMODE=true for deployment type 1, and migrate existing installs on update. The flag is misnamed upstream: it gates gevent isolation, not Docker. Also drop chromium.service. Nothing in Shelfmark connects to port 9222 — the bypasser launches its own browser on a random port — so it only consumed ~226MB. With DOCKERMODE enabled it is additionally killed by Shelfmark's orphan-process reaper (pkill -f chromium) on every bypass and respawned by systemd, since an LXC shares its PID namespace. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_012Ln3yVj3sWHG2c6T78W1we * Shelfmark: address review — one check, drop comments Collapse the chromium.service removal and the DOCKERMODE migration into the single internal-bypasser check, as every affected install has both. Guard the disable so a second update run does not fail on the removed unit, matching esphome.sh. Drop the explanatory comments. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_012Ln3yVj3sWHG2c6T78W1we --------- Co-authored-by: Claude Opus 5 (1M context) --- ct/shelfmark.sh | 12 ++++++++++-- install/shelfmark-install.sh | 17 +---------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/ct/shelfmark.sh b/ct/shelfmark.sh index e0ecbf45d..0461e8460 100644 --- a/ct/shelfmark.sh +++ b/ct/shelfmark.sh @@ -36,9 +36,18 @@ function update_script() { if check_for_gh_release "shelfmark" "calibrain/shelfmark"; then msg_info "Stopping Service(s)" systemctl stop shelfmark - [[ -f /etc/systemd/system/chromium.service ]] && systemctl stop chromium msg_ok "Stopped Service(s)" + if [[ $(sed -n '/_BYPASS=/s/[^=]*=//p' /etc/shelfmark/.env) == "true" ]] && + [[ $(sed -n '/BYPASSER=/s/[^=]*=//p' /etc/shelfmark/.env) == "false" ]]; then + msg_info "Updating internal bypasser configuration" + systemctl disable -q --now chromium 2>/dev/null || true + rm -f /etc/systemd/system/chromium.service + systemctl daemon-reload + sed -i '/DOCKERMODE=/s/false/true/' /etc/shelfmark/.env + msg_ok "Updated internal bypasser configuration" + fi + [[ -f /etc/systemd/system/flaresolverr.service ]] && if check_for_gh_release "flaresolverr" "Flaresolverr/Flaresolverr"; then msg_info "Stopping FlareSolverr service" systemctl stop flaresolverr @@ -79,7 +88,6 @@ function update_script() { msg_info "Starting Service(s)" systemctl start shelfmark - [[ -f /etc/systemd/system/chromium.service ]] && systemctl start chromium msg_ok "Started Service(s)" msg_ok "Updated successfully!" fi diff --git a/install/shelfmark-install.sh b/install/shelfmark-install.sh index c477caca3..308f97946 100644 --- a/install/shelfmark-install.sh +++ b/install/shelfmark-install.sh @@ -116,6 +116,7 @@ else chromium-common \ chromium \ python3-tk + sed -i '/DOCKERMODE=/s/false/true/' /etc/shelfmark/.env msg_ok "Installed internal bypasser dependencies" fi @@ -165,22 +166,6 @@ KillMode=mixed WantedBy=multi-user.target EOF -if [[ "$DEPLOYMENT_TYPE" == "1" ]]; then - cat </etc/systemd/system/chromium.service -[Unit] -Description=Chromium Headless Browser -After=network.target - -[Service] -User=root -ExecStart=/usr/bin/chromium --headless --no-sandbox --disable-gpu --disable-dev-shm-usage --remote-debugging-address=127.0.0.1 --remote-debugging-port=9222 --hide-scrollbars -Restart=always - -[Install] -WantedBy=multi-user.target -EOF - systemctl enable -q --now chromium -fi if [[ "$DEPLOYMENT_TYPE" == "2" ]]; then cat </etc/systemd/system/flaresolverr.service [Unit]