fix: reliable cloud sync and connection pooling for Render live dashboard
This commit is contained in:
@@ -11,7 +11,7 @@ import uvicorn
|
||||
from config import settings
|
||||
from database import engine, Base
|
||||
from contec_server import handle_contec_client
|
||||
from background_tasks import retry_failed_transmissions
|
||||
from background_tasks import retry_failed_transmissions, sync_cloud_state
|
||||
from routers import dashboard
|
||||
from routers.dashboard import get_ws_manager
|
||||
|
||||
@@ -138,8 +138,9 @@ async def lifespan(app: FastAPI):
|
||||
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
|
||||
# Startup: Start background retry and cloud state sync tasks
|
||||
retry_task = asyncio.create_task(retry_failed_transmissions())
|
||||
cloud_sync_task = asyncio.create_task(sync_cloud_state())
|
||||
|
||||
# Startup: Start bore tunnel for remote monitors if available and not already running
|
||||
bore_proc = None
|
||||
@@ -170,6 +171,7 @@ async def lifespan(app: FastAPI):
|
||||
except Exception:
|
||||
pass
|
||||
retry_task.cancel()
|
||||
cloud_sync_task.cancel()
|
||||
for server in servers:
|
||||
server.close()
|
||||
for server in servers:
|
||||
|
||||
Reference in New Issue
Block a user