class LibrixTCDaemon(QCoreApplication): """This class provides the main daemon for Librix Thin Client""" def __init__(self): """Instantiate LibrixTCDaemon class and exec init routines @param self A LibrixTCDaemon instance """ QCoreApplication.__init__(self, sys.argv) # Init LTCConfigParser self.configparser = LTCConfigParser() self.configparser.readConfigFile(configfile) # Init LTCModuleParser self.moduleparser = LTCModuleParser() # Start HTTP server self.httpserver = ThreadedServer(self.configparser, http_port) self.httpserver.start() # Init FileChecker instance and timer self.checkFile = FileChecker(self.configparser, self.moduleparser) self.checkFileTimer = QTimer(self) self.checkFileTimer.timeout.connect(self.checkFile.start) # Init UserChecker instance and timer self.checkUsers = UserChecker(self.configparser, self.moduleparser) self.checkUsersTimer = QTimer(self) self.checkUsersTimer.timeout.connect(self.checkUsers.start) # PID file checker self.checkPIDfileTimer = QTimer(self) self.checkPIDfileTimer.timeout.connect(self.checkPIDfile) self.checkFile.reload.connect(self.checkUsers.clearUser) # Start timers self.checkFileTimer.start(1000) self.checkUsersTimer.start(1000) self.checkPIDfileTimer.start(1000) def checkPIDfile(self): if not isfile(pidfile): self.stop() sys.exit(0) def stop(self): print("__STOPPING ALL") self.checkFileTimer.stop() self.checkUsersTimer.stop() for m in self.moduleparser.getModulesList(): self.moduleparser.stopModule(m)
def __init__(self): """Instantiate LibrixTCDaemon class and exec init routines @param self A LibrixTCDaemon instance """ QCoreApplication.__init__(self, sys.argv) # Init LTCConfigParser self.configparser = LTCConfigParser() self.configparser.readConfigFile(configfile) # Init LTCModuleParser self.moduleparser = LTCModuleParser() # Start HTTP server self.httpserver = ThreadedServer(self.configparser, http_port) self.httpserver.start() # Init FileChecker instance and timer self.checkFile = FileChecker(self.configparser, self.moduleparser) self.checkFileTimer = QTimer(self) self.checkFileTimer.timeout.connect(self.checkFile.start) # Init UserChecker instance and timer self.checkUsers = UserChecker(self.configparser, self.moduleparser) self.checkUsersTimer = QTimer(self) self.checkUsersTimer.timeout.connect(self.checkUsers.start) # PID file checker self.checkPIDfileTimer = QTimer(self) self.checkPIDfileTimer.timeout.connect(self.checkPIDfile) self.checkFile.reload.connect(self.checkUsers.clearUser) # Start timers self.checkFileTimer.start(1000) self.checkUsersTimer.start(1000) self.checkPIDfileTimer.start(1000)