Merge 69ffa30673
into d5026cf5ef
This commit is contained in:
commit
4857dcf803
1 changed files with 8 additions and 2 deletions
|
@ -93,6 +93,7 @@ class Manager(object):
|
||||||
t.add_to_loop(self._loop)
|
t.add_to_loop(self._loop)
|
||||||
u.add_to_loop(self._loop)
|
u.add_to_loop(self._loop)
|
||||||
self._relays[port] = (t, u)
|
self._relays[port] = (t, u)
|
||||||
|
self._statistics[port] = 0
|
||||||
|
|
||||||
def remove_port(self, config):
|
def remove_port(self, config):
|
||||||
port = int(config['server_port'])
|
port = int(config['server_port'])
|
||||||
|
@ -103,6 +104,7 @@ class Manager(object):
|
||||||
t.close(next_tick=False)
|
t.close(next_tick=False)
|
||||||
u.close(next_tick=False)
|
u.close(next_tick=False)
|
||||||
del self._relays[port]
|
del self._relays[port]
|
||||||
|
del self._statistics[port]
|
||||||
else:
|
else:
|
||||||
logging.error("server not exist at %s:%d" % (config['server'],
|
logging.error("server not exist at %s:%d" % (config['server'],
|
||||||
port))
|
port))
|
||||||
|
@ -127,7 +129,8 @@ class Manager(object):
|
||||||
self.remove_port(a_config)
|
self.remove_port(a_config)
|
||||||
self._send_control_data(b'ok')
|
self._send_control_data(b'ok')
|
||||||
elif command == 'ping':
|
elif command == 'ping':
|
||||||
self._send_control_data(b'pong')
|
# self._send_control_data(b'pong')
|
||||||
|
self._send_stat_data()
|
||||||
else:
|
else:
|
||||||
logging.error('unknown command %s', command)
|
logging.error('unknown command %s', command)
|
||||||
|
|
||||||
|
@ -153,6 +156,9 @@ class Manager(object):
|
||||||
self._statistics[port] += data_len
|
self._statistics[port] += data_len
|
||||||
|
|
||||||
def handle_periodic(self):
|
def handle_periodic(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _send_stat_data(self):
|
||||||
r = {}
|
r = {}
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
|
@ -173,7 +179,7 @@ class Manager(object):
|
||||||
i = 0
|
i = 0
|
||||||
if len(r) > 0:
|
if len(r) > 0:
|
||||||
send_data(r)
|
send_data(r)
|
||||||
self._statistics.clear()
|
# self._statistics.clear()
|
||||||
|
|
||||||
def _send_control_data(self, data):
|
def _send_control_data(self, data):
|
||||||
if not self._control_client_addr:
|
if not self._control_client_addr:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue