def run(self): self.api.start() self.next_run = time.time() while True: self.touch_member() logger.info(self.ha.run_cycle()) try: if self.ha.state_handler.is_leader(): self.ha.cluster and self.ha.state_handler.create_replication_slots( self.ha.cluster) # SkyDNS2 support: publish leader if self.skydns2: self.ha.dcs.client.set( self.skydns2['publish_leader'], '{{"host": "{0}", "port": {1}}}'.format( *self.postgresql.connect_address), ttl=self.skydns2['ttl']) else: self.ha.state_handler.drop_replication_slots() except: logger.exception('Exception when changing replication slots') reap_children() self.schedule_next_run()
def run(self): self.api.start() self.next_run = time.time() while True: self.touch_member() logger.info(self.ha.run_cycle()) try: if self.ha.state_handler.is_leader(): self.ha.cluster and self.ha.state_handler.create_replication_slots(self.ha.cluster) # SkyDNS2 support: publish leader if self.skydns2: self.ha.dcs.client.set(self.skydns2['publish_leader'], '{{"host": "{0}", "port": {1}}}'.format(*self.postgresql.connect_address), ttl=self.skydns2['ttl']) else: self.ha.state_handler.drop_replication_slots() except: logger.exception('Exception when changing replication slots') reap_children() self.schedule_next_run()
def test_reap_children(self): reap_children() os.waitpid = os_waitpid sigchld_handler(None, None) reap_children()