feat: show update service status in UI
This commit is contained in:
@ -220,3 +220,35 @@ def get_logs(settings: Settings, limit: int = 200) -> List[Dict[str, Any]]:
|
||||
except json.JSONDecodeError:
|
||||
continue
|
||||
return entries
|
||||
|
||||
|
||||
def get_service_status(settings: Settings) -> Dict[str, Any]:
|
||||
base_url = settings.update_service_url.rstrip("/")
|
||||
if not base_url:
|
||||
return {
|
||||
"url": "",
|
||||
"reachable": False,
|
||||
"status_code": None,
|
||||
"error": "update service url not configured",
|
||||
"checked_url": "",
|
||||
}
|
||||
|
||||
check_url = base_url
|
||||
try:
|
||||
with httpx.Client(timeout=3.0) as client:
|
||||
response = client.get(check_url)
|
||||
return {
|
||||
"url": base_url,
|
||||
"reachable": True,
|
||||
"status_code": response.status_code,
|
||||
"error": None,
|
||||
"checked_url": check_url,
|
||||
}
|
||||
except Exception as exc:
|
||||
return {
|
||||
"url": base_url,
|
||||
"reachable": False,
|
||||
"status_code": None,
|
||||
"error": str(exc),
|
||||
"checked_url": check_url,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user