import sys
import time
import threading
import pwd
import signal
from appBoot.logUtil import LogUtil
from dataAnalysisService.service.serviceOfDataAnalysis import ServiceOfDataAnalysis

logUtil=LogUtil()
logger=logUtil.getLogger()

class DaemonService:
    def __init__(self):
        self.stop_event = threading.Event()
        self.service=ServiceOfDataAnalysis()

    def run(self):
        while not self.stop_event.is_set():
            logger.info("Daemon is running...")
            self.service.run()

    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():
            logger.info("Daemon is not running.")
        else:
            logger.info("Daemon is running.")
