From 2fb462d51421abb65722e9d6206588484fed09df Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Tue, 4 Apr 2023 20:17:19 +0800 Subject: [PATCH] feat: add vector / dagu server --- tabby/admin/Home.py | 18 ++++++++++++++---- tabby/admin/utils/service_info.py | 6 ++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tabby/admin/Home.py b/tabby/admin/Home.py index 912f842..b120b3c 100644 --- a/tabby/admin/Home.py +++ b/tabby/admin/Home.py @@ -3,19 +3,29 @@ from components import monaco from utils.service_info import ServiceInfo SERVICES = [ - ServiceInfo(label="server", url="http://localhost:5000"), - ServiceInfo(label="triton", url="http://triton:8002/metrics"), + ServiceInfo(label="triton", health_url="http://triton:8002/metrics"), + ServiceInfo(label="vector", health_url="http://localhost:8686/health"), + ServiceInfo( + label="dagu", health_url="http://localhost:8080", url="http://localhost:8080" + ), + ServiceInfo( + label="server", health_url="http://localhost:5000", url="http://localhost:5000" + ), ] def make_badge_markdown(x: ServiceInfo): - return f"![{x.label}]({x.badge_url})" + badge = f"![{x.label}]({x.badge_url})" + if x.url: + return f"[{badge}]({x.url})" + else: + return badge st.set_page_config(page_title="Tabby Admin - Home") st.markdown("## Tabby") -st.markdown(" ".join(map(make_badge_markdown, SERVICES))) +st.markdown(" $~$ ".join(map(make_badge_markdown, SERVICES))) st.markdown("---") SNIPPETS = { diff --git a/tabby/admin/utils/service_info.py b/tabby/admin/utils/service_info.py index 0b84696..f725098 100644 --- a/tabby/admin/utils/service_info.py +++ b/tabby/admin/utils/service_info.py @@ -1,4 +1,5 @@ from dataclasses import dataclass +from typing import Optional import requests from requests.exceptions import ConnectionError @@ -7,12 +8,13 @@ from requests.exceptions import ConnectionError @dataclass class ServiceInfo: label: str - url: str + health_url: str + url: Optional[str] = None @property def is_health(self) -> bool: try: - return requests.get(self.url).status_code == 200 + return requests.get(self.health_url).status_code == 200 except ConnectionError: return False