import sys import time import threading import pwd import signal class DaemonService: def __init__(self): self.stop_event = threading.Event() def run(self): while not self.stop_event.is_set(): print("Daemon is running...") time.sleep(5) def start(self): self.stop_event.clear() thread = threading.Thread(target=self.run) thread.start() def stop(self): self.stop_event.set() def status(self): if self.stop_event.is_set(): print("Daemon is not running.") else: print("Daemon is running.")