def publish(self, obj): url = "http://%s:%s/publish" %(self._server_ip, self._server_port) body = json.dumps(obj.exportDict()) response = requests.post(url, data = body, headers = self._headers) print 'Register response = ', response # send published information as heartbeat data hc = HealthCheck(self._server_ip, int(self._server_port)) hc.set_heartbeat_data(response.text) return gevent.spawn(hc.client)
def main(args_str = None): server = DiscoveryServer(args_str) pipe_start_app = server.get_pipe_start_app() hc = HealthCheck(server.get_ip_addr(), server.get_port()) hc.set_server_callback(server.heartbeat) gevent.spawn(hc.server) try: bottle.run(app = pipe_start_app, host = server.get_ip_addr(), port = server.get_port(), server = 'gevent') except Exception as e: # cleanup gracefully server.cleanup()
def main(args_str=None): server = DiscoveryServer(args_str) pipe_start_app = server.get_pipe_start_app() hc = HealthCheck(server.get_ip_addr(), server.get_port()) hc.set_server_callback(server.heartbeat) gevent.spawn(hc.server) try: bottle.run(app=pipe_start_app, host=server.get_ip_addr(), port=server.get_port(), server='gevent') except Exception as e: # cleanup gracefully server.cleanup()