class AppCore(Greenlet): def __init__(self, vhost_data): Greenlet.__init__(self) self.vhost_data = vhost_data self.app1 = AppServer(usr=self.vhost_data['user'], pwd=self.vhost_data['password'], host=self.vhost_data['host'], port=self.vhost_data['port'], vhost=self.vhost_data['name']) self.c = Caller() def _run(self): current_thread().name = self.vhost_data['name'] while 1: # reload config importlib.reload(coreconfig) # begin get vhosts & ips self.ips = self.c.getIPS(coreconfig.CoreConfig.URL_GET_LIST_IP, self.vhost_data['name']) # self.ips = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] if self.app1 is not None: self.app1.push(self.ips) time.sleep(coreconfig.CoreConfig.PING_INTERVAL_SECONDS)
class AppCore(Greenlet): def __init__(self, vhost_data): Greenlet.__init__(self) self.vhost_data = vhost_data self.app1 = AppServer(usr=self.vhost_data['user'], pwd=self.vhost_data['password'], host=self.vhost_data['host'], port=self.vhost_data['port'], vhost=self.vhost_data['name']) self.c = Caller() def _run(self): current_thread().name = self.vhost_data['name'] while 1: # reload config importlib.reload(coreconfig) # begin get vhosts & ips self.ips = self.c.getIPS(coreconfig.CoreConfig.URL_GET_LIST_IP, self.vhost_data['name']) # self.ips = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] if self.app1 is not None: self.app1.push(self.ips) time.sleep(coreconfig.CoreConfig.PING_INTERVAL_SECONDS)
class AppCore(Greenlet): def __init__(self, vhost_data): Greenlet.__init__(self) self.vhost_data = vhost_data self.app1 = AppServer(usr=self.vhost_data['user'], pwd=self.vhost_data['password'], host=self.vhost_data['host'], port=self.vhost_data['port'], vhost=self.vhost_data['name']) self.c = Caller() def _run(self): current_thread().name = self.vhost_data['name'] while 1: # reload config importlib.reload(coreconfig) # check if app is None logging.info("[AppCore] Current app is: {0}".format(self.app1)) if not self.app1.is_init: # re-initate logging.info("[AppCore] App isn't init properly. Re-initiate now ...") self.app1 = AppServer(usr=self.vhost_data['user'], pwd=self.vhost_data['password'], host=self.vhost_data['host'], port=self.vhost_data['port'], vhost=self.vhost_data['name']) logging.info("[AppCore] Now sleeping {0}s...".format(coreconfig.CoreConfig.PING_INTERVAL_SECONDS)) time.sleep(coreconfig.CoreConfig.PING_INTERVAL_SECONDS) # yes, ignore to continue continue # begin get vhosts & ips logging.info("[AppCore] Begin getting IPs ...") self.ips = self.c.getIPS(coreconfig.CoreConfig.URL_GET_LIST_IP, self.vhost_data['name']) # self.ips = ['192.168.1.1', '192.168.1.2', '192.168.1.3'] if self.app1.is_init and self.ips: self.app1.push(self.ips) else: logging.info("[AppCore] Nothing to push (app is None or get IPs failed)") logging.info("[AppCore] Now sleeping {0}s...".format(coreconfig.CoreConfig.PING_INTERVAL_SECONDS)) time.sleep(coreconfig.CoreConfig.PING_INTERVAL_SECONDS)