forked from M-Labs/artiq
dashboard: report lost connection with master. Closes #602
This commit is contained in:
parent
dcea48a52d
commit
3aced46b19
|
@ -108,12 +108,21 @@ def main():
|
|||
atexit.register(client.close_rpc)
|
||||
rpc_clients[target] = client
|
||||
|
||||
disconnect_reported = False
|
||||
def report_disconnect():
|
||||
nonlocal disconnect_reported
|
||||
if not disconnect_reported:
|
||||
logging.error("connection to master lost, "
|
||||
"restart dashboard to reconnect")
|
||||
disconnect_reported = True
|
||||
|
||||
sub_clients = dict()
|
||||
for notifier_name, modelf in (("explist", explorer.Model),
|
||||
("explist_status", explorer.StatusUpdater),
|
||||
("datasets", datasets.Model),
|
||||
("schedule", schedule.Model)):
|
||||
subscriber = ModelSubscriber(notifier_name, modelf)
|
||||
subscriber = ModelSubscriber(notifier_name, modelf,
|
||||
report_disconnect)
|
||||
loop.run_until_complete(subscriber.connect(
|
||||
args.server, args.port_notify))
|
||||
atexit_register_coroutine(subscriber.close)
|
||||
|
@ -121,7 +130,7 @@ def main():
|
|||
|
||||
broadcast_clients = dict()
|
||||
for target in "log", "ccb":
|
||||
client = Receiver(target, [])
|
||||
client = Receiver(target, [], report_disconnect)
|
||||
loop.run_until_complete(client.connect(
|
||||
args.server, args.port_broadcast))
|
||||
atexit_register_coroutine(client.close)
|
||||
|
|
|
@ -22,9 +22,11 @@ class ModelManager:
|
|||
|
||||
|
||||
class ModelSubscriber(ModelManager, Subscriber):
|
||||
def __init__(self, notifier_name, model_factory):
|
||||
def __init__(self, notifier_name, model_factory,
|
||||
disconnect_cb=None):
|
||||
ModelManager.__init__(self, model_factory)
|
||||
Subscriber.__init__(self, notifier_name, self._create_model)
|
||||
Subscriber.__init__(self, notifier_name, self._create_model,
|
||||
disconnect_cb=disconnect_cb)
|
||||
|
||||
|
||||
class LocalModelManager(ModelManager):
|
||||
|
|
Loading…
Reference in New Issue