def __init__(self, fd=42): self.pid = os.getpid() with os.fdopen(fd, 'r') as f: self.cfg = json.loads(f.read()) self._log = os.fdopen(0, 'w', 1).write set_proc_title(self.name) set_pdeathsig(signal.SIGTERM) def _sigusr1(SIG, FRM): self.sigusr1() signal.signal(signal.SIGUSR1, _sigusr1) def _sigusr2(SIG, FRM): self.sigusr2() signal.signal(signal.SIGUSR2, _sigusr2) def excepthook(*exc_info): self.log("".join(traceback.format_exception(*exc_info))) sys.excepthook = excepthook reactor.addSystemEventTrigger("before", "shutdown", self.shutdown)
def __init__(self): self.welcome_msg = False self.start_defer = Deferred() process.set_pdeathsig(signal.SIGTERM)