Files
dj/integration-work/inspect_three_comfy_interfaces.py
T

24 lines
1.6 KiB
Python

import json,subprocess,urllib.request,urllib.error
ids=subprocess.check_output(['docker','ps','-q'],text=True).split()
for cid in ids:
d=json.loads(subprocess.check_output(['docker','inspect',cid],text=True))[0]
name=d['Name'].lstrip('/'); ports=d['NetworkSettings'].get('Ports') or {}
published={x.get('HostPort') for values in ports.values() for x in (values or [])}
if not ('comfy' in name or published.intersection({'8188','8189','8191'})):continue
print(json.dumps({'container':name,'ports':ports,'gpu':d['HostConfig'].get('DeviceRequests'),
'image':d['Config']['Image'],'networks':{k:{'ip':v.get('IPAddress'),'aliases':v.get('Aliases')} for k,v in d['NetworkSettings']['Networks'].items()}}))
print(subprocess.check_output(['ss','-ltn'],text=True))
for port in (8188,8189,8191):
for endpoint in ('/','/system_stats'):
try:
with urllib.request.urlopen(f'http://192.168.110.111:{port}'+endpoint,timeout=10) as r:
content=r.read(); report={'port':port,'path':endpoint,'status':r.status,'type':r.headers.get('Content-Type')}
if endpoint=='/system_stats':
try:report['devices']=json.loads(content).get('devices')
except ValueError:pass
print(json.dumps(report))
except Exception as e:print(json.dumps({'port':port,'path':endpoint,'error':type(e).__name__,'status':getattr(e,'code',None)}))
for name in ('canvas-h3-prompt-normalizer-healthy-20261026','huobao-vdn-normalizer'):
code="import app,json;print(json.dumps([{'id':p.id,'url':p.base_url} for p in app.providers().values()]))"
print(name,subprocess.check_output(['docker','exec',name,'python','-c',code],text=True))