goon/scripts/killall_bulk_rescrape.py
goon-foss ad0284585b Initial commit
Goon — self-hosted aggregator for adult-content scene metadata.

Indexes scenes from TPDB, StashDB, and 30+ public adult tube sites.
Cross-source deduplication via perceptual hash + Levenshtein distance.
FastAPI backend + APScheduler worker + React Native (Expo) mobile client.

FOSS, ad-free, donation-funded. See README for details.
2026-05-20 10:10:22 +02:00

39 lines
1.1 KiB
Python

"""One-off helper: zabij wszystkie running `bulk_rescrape_hqporner` Python procesy
w containerze. `pkill`/`kill` nie są dostępne w obrazie, więc używamy `os.kill`
po wyszukaniu PIDów w /proc.
"""
import glob
import os
import signal
self_pid = os.getpid()
killed: list[int] = []
found: list[tuple[int, str]] = []
for p in glob.glob("/proc/[0-9]*/cmdline"):
try:
with open(p, "rb") as f:
raw = f.read()
except Exception:
continue
cmd = raw.replace(b"\x00", b" ").decode("utf-8", errors="ignore")
if "bulk_rescrape_hqporner" in cmd:
try:
pid = int(p.split("/")[2])
except ValueError:
continue
if pid == self_pid:
continue
found.append((pid, cmd[:120]))
print(f"found {len(found)} bulk_rescrape processes:")
for pid, cmd in found:
print(f" pid={pid} cmd={cmd}")
try:
os.kill(pid, signal.SIGTERM)
killed.append(pid)
except ProcessLookupError:
pass
except Exception as e:
print(f" fail kill {pid}: {e}")
print(f"killed: {killed}")