Auto headless + Xvfb for headless servers
Enable Chromium on machines without DISPLAY: Python auto headless with Xvfb hints, and start.sh installs/starts Xvfb (xvfb-run or persistent :99) so registration can run headed under a virtual display.
This commit is contained in:
1 parent
4feac70c91
commit
cd4a2351ae
8 files changed
+536
-21
No files matched your search
+32
-2
@@ -351,8 +351,38 @@ def export_cpa_xai_for_account(
|
||||
or os.environ.get("http_proxy")
|
||||
or ""
|
||||
).strip()
|
||||
# Default headed: headless is frequently Cloudflare-blocked on accounts.x.ai
|
||||
headless = bool(cfg.get("cpa_headless", False))
|
||||
# Default headed when a display exists; headless is frequently Cloudflare-blocked.
|
||||
# On servers without DISPLAY, always force headless so Chromium can start.
|
||||
has_disp = sys.platform == "win32" or bool(
|
||||
(os.environ.get("DISPLAY") or "").strip()
|
||||
or (os.environ.get("WAYLAND_DISPLAY") or "").strip()
|
||||
)
|
||||
cpa_hl_raw = cfg.get("cpa_headless", None)
|
||||
if cpa_hl_raw is None:
|
||||
# inherit browser_headless auto / explicit if set
|
||||
cpa_hl_raw = cfg.get("browser_headless", "auto")
|
||||
if isinstance(cpa_hl_raw, bool):
|
||||
headless = cpa_hl_raw
|
||||
else:
|
||||
s = str(cpa_hl_raw or "auto").strip().lower()
|
||||
if s in ("1", "true", "yes", "on", "headless"):
|
||||
headless = True
|
||||
elif s in ("0", "false", "no", "off", "headed", "gui"):
|
||||
headless = False
|
||||
else:
|
||||
headless = not has_disp
|
||||
if not has_disp and not headless:
|
||||
headless = True
|
||||
_log(
|
||||
f"cpa browser forced headless (no DISPLAY={os.environ.get('DISPLAY', '')!r}); "
|
||||
"prefer xvfb-run for Turnstile; protocol mint still preferred first"
|
||||
)
|
||||
elif headless and not bool(cfg.get("cpa_headless", False)):
|
||||
_log(
|
||||
"cpa browser headless auto/on "
|
||||
f"(DISPLAY={os.environ.get('DISPLAY', '')!r}); "
|
||||
"protocol mint still preferred first"
|
||||
)
|
||||
probe = bool(cfg.get("cpa_probe_after_write", True))
|
||||
probe_chat = bool(cfg.get("cpa_probe_chat", False))
|
||||
timeout = float(cfg.get("cpa_mint_timeout_sec", 240))
|
||||
|
||||
Reference in new issue
Block a user