Delete pid_utils.py and migrate to Process model

DELETED:
- workers/pid_utils.py (-192 lines) - replaced by Process model methods

SIMPLIFIED:
- crawls/models.py Crawl.cleanup() (80 lines -> 10 lines)
- hooks.py: deleted process_is_alive() and kill_process() (-45 lines)

UPDATED to use Process model:
- core/models.py: Snapshot.cleanup() and has_running_background_hooks()
- machine/models.py: Binary.cleanup()
- workers/worker.py: Worker.on_startup/shutdown, get_running_workers, start
- workers/orchestrator.py: Orchestrator.on_startup/shutdown, is_running

All subprocess management now uses:
- Process.current() for registering current process
- Process.get_running() / get_running_count() for querying
- Process.cleanup_stale_running() for cleanup
- safe_kill_process() for validated PID killing

Total line reduction: ~250 lines
This commit is contained in:
Claude
2025-12-31 10:15:22 +00:00
parent 2d3a2fec57
commit b822352fc3
7 changed files with 63 additions and 359 deletions

View File

@@ -449,7 +449,7 @@ class Binary(ModelWithHealthStats):
since installations are foreground, but included for consistency).
"""
from pathlib import Path
from archivebox.hooks import kill_process
from archivebox.misc.process_utils import safe_kill_process
output_dir = self.OUTPUT_DIR
if not output_dir.exists():
@@ -460,8 +460,8 @@ class Binary(ModelWithHealthStats):
if not plugin_dir.is_dir():
continue
pid_file = plugin_dir / 'hook.pid'
if pid_file.exists():
kill_process(pid_file)
cmd_file = plugin_dir / 'cmd.sh'
safe_kill_process(pid_file, cmd_file)
# =============================================================================