From 5a35117299924bc354990fcd5aca2b778f825170 Mon Sep 17 00:00:00 2001 From: Levi <13402525+LeviSnoot@users.noreply.github.com> Date: Tue, 3 Jun 2025 15:24:57 +0200 Subject: [PATCH 1/2] fix: handle zombie processes --- Dockerfile | 4 ++-- src/utils.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index cf62aaa..88e64e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ENV GITHUB_BUILD=${GITHUB_BUILD}\ WORKDIR /app RUN apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests xauth xvfb scrot curl chromium chromium-driver ca-certificates + apt-get install -y --no-install-recommends --no-install-suggests xauth xvfb scrot curl chromium chromium-driver ca-certificates tini ADD https://astral.sh/uv/install.sh install.sh RUN sh install.sh && uv --version @@ -44,4 +44,4 @@ RUN ./test.sh FROM app EXPOSE 8191 HEALTHCHECK --interval=15m --timeout=30s --start-period=5s --retries=3 CMD [ "curl", "http://localhost:8191/health" ] -ENTRYPOINT ["uv", "run", "main.py"] +ENTRYPOINT ["/usr/bin/tini", "--", "uv", "run", "main.py"] diff --git a/src/utils.py b/src/utils.py index 1816247..34b87a8 100644 --- a/src/utils.py +++ b/src/utils.py @@ -27,14 +27,19 @@ def get_sb( detail="SOCKS5 proxy with authentication is not supported. Check README for more info.", ) - with SB( + sb_ctx = SB( uc=True, headless=USE_HEADLESS, locale_code="en", ad_block=True, proxy=proxy, - ) as sb: + ) + sb = sb_ctx.__enter__() + try: yield sb + finally: + sb_ctx.__exit__(None, None, None) + def save_screenshot(sb: BaseCase): From 9353daaf1aeb1487aa8b1d677b9d96c34e609aa7 Mon Sep 17 00:00:00 2001 From: Levi <13402525+LeviSnoot@users.noreply.github.com> Date: Wed, 4 Jun 2025 01:26:47 +0200 Subject: [PATCH 2/2] revert refactor of `src/utils.py` --- src/utils.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/utils.py b/src/utils.py index 34b87a8..1816247 100644 --- a/src/utils.py +++ b/src/utils.py @@ -27,19 +27,14 @@ def get_sb( detail="SOCKS5 proxy with authentication is not supported. Check README for more info.", ) - sb_ctx = SB( + with SB( uc=True, headless=USE_HEADLESS, locale_code="en", ad_block=True, proxy=proxy, - ) - sb = sb_ctx.__enter__() - try: + ) as sb: yield sb - finally: - sb_ctx.__exit__(None, None, None) - def save_screenshot(sb: BaseCase):