Update backend/api/routes/health.py: circuit breaker, weather fix, TB health fix
Browse files
backend/api/routes/health.py
CHANGED
|
@@ -13,14 +13,14 @@ router = APIRouter()
|
|
| 13 |
|
| 14 |
|
| 15 |
async def _check_thingsboard() -> bool:
|
| 16 |
-
"""Check ThingsBoard connectivity
|
| 17 |
tb_host = os.environ.get("THINGSBOARD_HOST", "")
|
| 18 |
if not tb_host:
|
| 19 |
return False
|
| 20 |
try:
|
| 21 |
import urllib.request
|
| 22 |
-
|
| 23 |
-
|
| 24 |
loop = asyncio.get_event_loop()
|
| 25 |
resp = await loop.run_in_executor(
|
| 26 |
None, lambda: urllib.request.urlopen(url, timeout=3)
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
async def _check_thingsboard() -> bool:
|
| 16 |
+
"""Check ThingsBoard connectivity by hitting the login page."""
|
| 17 |
tb_host = os.environ.get("THINGSBOARD_HOST", "")
|
| 18 |
if not tb_host:
|
| 19 |
return False
|
| 20 |
try:
|
| 21 |
import urllib.request
|
| 22 |
+
# Use root URL — TB always responds to GET / with 200 (login page)
|
| 23 |
+
url = tb_host.rstrip("/") + "/"
|
| 24 |
loop = asyncio.get_event_loop()
|
| 25 |
resp = await loop.run_in_executor(
|
| 26 |
None, lambda: urllib.request.urlopen(url, timeout=3)
|