refactor: implement packet parsing heuristics and introduce device-level state caching to throttle database writes and vitals updates
This commit is contained in:
@@ -91,18 +91,22 @@ async def lifespan(app: FastAPI):
|
||||
for s in servers:
|
||||
for sock in s.sockets:
|
||||
active_ports.append(sock.getsockname()[1])
|
||||
app.state.active_ports = active_ports
|
||||
logger.info(f" Active listener ports: {active_ports}")
|
||||
else:
|
||||
app.state.active_ports = []
|
||||
logger.error("No servers could be started! Check port availability and permissions.")
|
||||
|
||||
# === Print startup banner ===
|
||||
import os
|
||||
port = int(os.environ.get("PORT", 8000))
|
||||
local_ips = _get_local_ips()
|
||||
model = settings.monitor_model
|
||||
print("\n" + "=" * 65)
|
||||
print(f" Contec {model} Patient Monitor - Vital Signs Forwarder")
|
||||
print("=" * 65)
|
||||
print(f" DASHBOARD: http://localhost:8000/api/dashboard")
|
||||
print(f" API Docs: http://localhost:8000/docs")
|
||||
print(f" DASHBOARD: http://localhost:{port}/api/dashboard")
|
||||
print(f" API Docs: http://localhost:{port}/docs")
|
||||
print(f" Contec Ports: {settings.contec_ports}")
|
||||
print(f" Monitor Model: {model}")
|
||||
print(f" API Target: {settings.target_api_url}")
|
||||
@@ -114,7 +118,7 @@ async def lifespan(app: FastAPI):
|
||||
print("=" * 65)
|
||||
print(f" Waiting for {model} connections...")
|
||||
print(f" On your monitor: System Setup > Network > CMS Settings")
|
||||
print(f" Set Server IP = one of the IPs above, Port = 511")
|
||||
print(f" Set Server IP = one of the IPs above, Port = {settings.contec_ports[0] if settings.contec_ports else 511}")
|
||||
print("=" * 65 + "\n")
|
||||
|
||||
# Startup: Start the background retry task
|
||||
@@ -165,5 +169,7 @@ if __name__ == "__main__":
|
||||
logger.info("Initializing Application...")
|
||||
|
||||
# Run the FastAPI server.
|
||||
# Notice we run on port 8000 for the REST Dashboard, while HL7 is on settings.hl7_port (e.g. 6060)
|
||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||
# Notice we run on port 8000 (or PORT env var) for the REST Dashboard, while HL7 is on settings.hl7_port (e.g. 6060)
|
||||
import os
|
||||
port = int(os.environ.get("PORT", 8000))
|
||||
uvicorn.run(app, host="0.0.0.0", port=port)
|
||||
|
||||
Reference in New Issue
Block a user