Returns bool - True = alive, False = error or cannot connect. """ res = True try: if self.db_conn is None: res = False else: # ping and is_connected only work partially, try exec_query # to make sure connection is really alive retval = self.db_conn.is_connected() if retval: self.exec_query("SHOW DATABASES") else: res = False except: res = False return res Health Check時に MySQLに接続し SHOW DATABASESを実行 111
method tries to reconnect to the mast after 3 attemps, returns False. """ if self.master and self.master.is_alive(): return True is_connected = False i = 0 while i < 3: try: self.master.connect() is_connected = True break except: pass time.sleep(pingtime) i += 1 return is_connected 失敗した場合は ping(pingtime) x3 試す x3はハードコードされている 112
https://www-jp.mysql.com/ MySQL Utilities https://dev.mysql.com/downloads/utilities/ Consul by HashiCorp https://www.consul.io/ consul-template https://github.com/hashicorp/consul-template Dnsmasq - network services for small networks. - Simon Kelley http://www.thekelleys.org.uk/dnsmasq/doc.html Consulと自作OSSを活用した100台規模のWebサービス運用 by FUJIWARA Shunichiro https://speakerdeck.com/fujiwara3/consultozi-zuo-osswohuo-yong-sita100tai-gui-mo- falsewebsabisuyun-yong 参考URL 155