Add service categories and also unbreak things
This commit is contained in:
+6
-5
@@ -5,10 +5,11 @@ import time
|
||||
import httpx
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from jinja2 import Environment, PackageLoader
|
||||
|
||||
from velping.config import Config, ServiceConfig, load_cfg
|
||||
from velping.config import HTTPServiceConfig, TCPServiceConfig, load_cfg
|
||||
|
||||
http = httpx.Client(
|
||||
headers={"User-Agent": "velping"},
|
||||
@@ -46,7 +47,7 @@ def handle_service_status(
|
||||
print(f"[I] Pinging {service_name} succeeded!")
|
||||
|
||||
|
||||
def tcp_ping(service: ServiceConfig) -> None:
|
||||
def tcp_ping(service: TCPServiceConfig) -> None:
|
||||
"""Continuously ping a service via TCP."""
|
||||
|
||||
socket_type = socket.AF_INET if service.ipv == 4 else socket.AF_INET6
|
||||
@@ -77,7 +78,7 @@ def tcp_ping(service: ServiceConfig) -> None:
|
||||
time.sleep(cfg.pinging.rate)
|
||||
|
||||
|
||||
def http_ping(service: ServiceConfig) -> None:
|
||||
def http_ping(service: HTTPServiceConfig) -> None:
|
||||
"""Continuously ping a service via HTTP."""
|
||||
while True:
|
||||
print(f"[I] Pinging {service.name}")
|
||||
@@ -97,8 +98,8 @@ def http_ping(service: ServiceConfig) -> None:
|
||||
time.sleep(cfg.pinging.rate)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root(cfg: Config) -> str:
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def root() -> str:
|
||||
template = templates.get_template("index.xht")
|
||||
return template.render(
|
||||
cfg=cfg,
|
||||
|
||||
Reference in New Issue
Block a user