This repository has been archived on 2025-11-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Fitz_Studio/scripts/mcps/cerrar_mcps.py
T

35 lines
1.0 KiB
Python

import os
import signal
import time
PID_FILE = "mcps.pid"
def cerrar_procesos(pid_file):
if not os.path.exists(pid_file):
print(f"❌ No se encontró el archivo {pid_file}")
return
with open(pid_file, "r") as f:
pids = [line.strip() for line in f if line.strip().isdigit()]
for pid_str in pids:
pid = int(pid_str)
try:
os.kill(pid, signal.SIGTERM)
print(f"✔ Proceso {pid} terminado con SIGTERM.")
except ProcessLookupError:
print(f"⚠ El proceso {pid} no existe o ya fue terminado.")
except PermissionError:
print(f"❌ No tienes permiso para terminar el proceso {pid}.")
except Exception as e:
print(f"❌ Error al cerrar el proceso {pid}: {e}")
try:
os.remove(pid_file)
print(f"🧹 Archivo {pid_file} eliminado.")
except Exception as e:
print(f"⚠ No se pudo eliminar {pid_file}: {e}")
if __name__ == "__main__":
cerrar_procesos(PID_FILE)