def run(self): while True: time.sleep(4) try: line = sys.stdin.readline() if not line: continue if line == 'stop\n': try: kkbLib.rmPid('agent') self.agentProcess.stop() self.masterMonitor.stop() finally: os._exit(0) if line == 'restart\n': self.agentProcess.restart() if line == 'ping\n': self.masterMonitor.heartbeat() continue except Exception: kkbLib.error(traceback.format_exc())
def run(self): while self.running: time.sleep(4) try: try: self.lock.acquire() if (time.time() - self.lastHeartbeat) > 12: self.agentProcess.stop() kkbLib.rmPid('agent') os._exit(0) finally: self.lock.release() except Exception: kkbLib.error(traceback.format_exc()) raise
def stop(self): # Get the pid from the pidfile try: pid = kkbLib.readPid('master') except IOError: pid = None if not pid: message = "The process does not exist, the operation aborts" kkbLib.printout(message) kkbLib.info(message) return # not an error in a restart # Try killing the daemon process try: while 1: os.kill(pid, SIGTERM) time.sleep(0.1) except OSError: kkbLib.rmPid('agent') kkbLib.rmPid('master') kkbLib.printout('Successful process closes') kkbLib.info('Successful process closes')
def __del__(self): kkbLib.rmPid('agent')
def restart(self): kkbLib.rmPid('agent') os._exit(0)
def __del__(self): kkbLib.rmPid('agent') kkbLib.rmPid('master')
def delpid(self): kkbLib.rmPid('agent') kkbLib.rmPid('master')