Broker unterstützt jetzt mehrere WSGI Worker
This commit is contained in:
1 parent
1e2a58e563
commit
f5b0c9509c
13 files changed
+1252
-327
No files matched your search
+17
-31
@@ -356,38 +356,24 @@ def import_streets(**kwargs):
|
||||
@admin_api_bp.route('/broker/status')
|
||||
@role_required('Administrator')
|
||||
def broker_status(**kwargs):
|
||||
"""Status aktiver WebSocket-Verbindungen"""
|
||||
connections = broker.connections.get(g.tenant_id, {}) if hasattr(broker, 'connections') else {}
|
||||
"""Status aktiver WebSocket-Verbindungen aller Worker.
|
||||
|
||||
Die Verbindungsliste liegt in der gemeinsamen Tabelle ``ws_clients``.
|
||||
Dadurch zeigt das Dashboard auch Clients, die an einem anderen
|
||||
WSGI-Worker hängen.
|
||||
"""
|
||||
connections = broker.describe_connections(g.tenant_id)
|
||||
result = []
|
||||
for client_id, conn in connections.items():
|
||||
account_id = conn.get('account_id')
|
||||
account = get_db().execute(
|
||||
'SELECT id, name, role FROM accounts WHERE id = ? AND tenant_id = ?',
|
||||
(account_id, g.tenant_id)
|
||||
).fetchone()
|
||||
if not account:
|
||||
continue
|
||||
entry = {
|
||||
'client_id': client_id,
|
||||
'account_id': account['id'],
|
||||
'account_name': account['name'],
|
||||
'role': account['role'],
|
||||
'authenticated': broker.is_authenticated(g.tenant_id, client_id),
|
||||
'group_id': None,
|
||||
'group_alias': None
|
||||
}
|
||||
if account['role'] == 'Gruppe':
|
||||
group = get_db().execute(
|
||||
'''SELECT g.id, g.aliasname FROM groups g
|
||||
JOIN group_accounts ga
|
||||
ON ga.group_id = g.id AND ga.tenant_id = g.tenant_id
|
||||
WHERE ga.account_id = ? AND g.tenant_id = ?''',
|
||||
(account['id'], g.tenant_id)
|
||||
).fetchone()
|
||||
if group:
|
||||
entry['group_id'] = group['id']
|
||||
entry['group_alias'] = group['aliasname']
|
||||
result.append(entry)
|
||||
for conn in connections:
|
||||
result.append({
|
||||
'client_id': conn['client_id'],
|
||||
'account_id': conn['account_id'],
|
||||
'account_name': conn['account_name'],
|
||||
'role': conn['role'],
|
||||
'authenticated': bool(conn['authenticated']),
|
||||
'group_id': conn['group_id'],
|
||||
'group_alias': conn['group_alias']
|
||||
})
|
||||
return jsonify({'connections': result})
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user