Files
root f56b088643
Base Image Build / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
Base Image Build / docker (amd64, ubuntu-24.04) (push) Has been cancelled
Base Image Build / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
Base Image Build / create-manifest (push) Has been cancelled
Proyecto LCX Dispatcharr multicuenta
2026-05-09 21:24:50 +02:00

28 lines
1.1 KiB
Python

# core/management/commands/kill_processes.py
import psutil
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Kills all processes with 'ffmpeg' or 'streamlink' in their name or command line."
def handle(self, *args, **options):
kill_count = 0
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
try:
name = proc.info.get('name') or ''
cmdline = ' '.join(proc.info.get('cmdline') or [])
lower_name = name.lower()
lower_cmdline = cmdline.lower()
if ('ffmpeg' in lower_name or 'ffmpeg' in lower_cmdline or
'streamlink' in lower_name or 'streamlink' in lower_cmdline):
self.stdout.write(f"Killing PID {proc.pid}: {name} {cmdline}")
proc.kill()
kill_count += 1
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
continue
self.stdout.write(self.style.SUCCESS(f"Killed {kill_count} processes."))