feat: add vector / dagu server

add-more-languages
Meng Zhang 2023-04-04 20:17:19 +08:00
parent 0584f8e88e
commit 2fb462d514
2 changed files with 18 additions and 6 deletions

View File

@ -3,19 +3,29 @@ from components import monaco
from utils.service_info import ServiceInfo from utils.service_info import ServiceInfo
SERVICES = [ SERVICES = [
ServiceInfo(label="server", url="http://localhost:5000"), ServiceInfo(label="triton", health_url="http://triton:8002/metrics"),
ServiceInfo(label="triton", 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): 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.set_page_config(page_title="Tabby Admin - Home")
st.markdown("## Tabby") st.markdown("## Tabby")
st.markdown(" ".join(map(make_badge_markdown, SERVICES))) st.markdown(" $~$ ".join(map(make_badge_markdown, SERVICES)))
st.markdown("---") st.markdown("---")
SNIPPETS = { SNIPPETS = {

View File

@ -1,4 +1,5 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import Optional
import requests import requests
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
@ -7,12 +8,13 @@ from requests.exceptions import ConnectionError
@dataclass @dataclass
class ServiceInfo: class ServiceInfo:
label: str label: str
url: str health_url: str
url: Optional[str] = None
@property @property
def is_health(self) -> bool: def is_health(self) -> bool:
try: try:
return requests.get(self.url).status_code == 200 return requests.get(self.health_url).status_code == 200
except ConnectionError: except ConnectionError:
return False return False