import signal
import threading

class SystemdKiller:
    def __init__(self):
        self.exit_event = threading.Event()
        signal.signal(signal.SIGINT, self.exit_handler)
        signal.signal(signal.SIGTERM, self.exit_handler)

    def exit_handler(self, signum, frame):
        self.exit_event.set()  # Устанавливаем флаг прерывания
