mirror of
https://github.com/pacnpal/simpleguardhome.git
synced 2025-12-19 20:11:14 -05:00
feat(healthcheck): enhance health check functionality and serve favicon directly
This commit is contained in:
@@ -5,10 +5,11 @@ import os
|
|||||||
|
|
||||||
def check_health():
|
def check_health():
|
||||||
try:
|
try:
|
||||||
host = os.environ.get('ADGUARD_HOST', 'http://localhost')
|
host = os.environ.get('ADGUARD_HOST', 'localhost')
|
||||||
port = os.environ.get('ADGUARD_PORT', '8000')
|
port = os.environ.get('ADGUARD_PORT', '8000')
|
||||||
|
url = f'http://{host}:{port}/health'
|
||||||
with httpx.Client() as client:
|
with httpx.Client() as client:
|
||||||
response = client.get('http://localhost:8000/health')
|
response = client.get(url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
print('✅ Service is healthy')
|
print('✅ Service is healthy')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
@@ -59,10 +59,19 @@ templates = Jinja2Templates(directory=str(templates_path))
|
|||||||
# Mount static files from package directory
|
# Mount static files from package directory
|
||||||
app.mount("/static", StaticFiles(directory=str(Path(__file__).parent)), name="static")
|
app.mount("/static", StaticFiles(directory=str(Path(__file__).parent)), name="static")
|
||||||
|
|
||||||
# Mount favicon.ico at root
|
# Serve favicon.ico directly
|
||||||
static_files_path = Path(__file__).parent
|
from fastapi.responses import FileResponse
|
||||||
app.mount("/favicon.ico",
|
favicon_path = Path(__file__).parent / "favicon.ico"
|
||||||
StaticFiles(directory=str(static_files_path)), name="favicon")
|
|
||||||
|
@app.get("/favicon.ico")
|
||||||
|
async def favicon():
|
||||||
|
"""Serve favicon."""
|
||||||
|
return FileResponse(favicon_path)
|
||||||
|
|
||||||
|
@app.get("/health")
|
||||||
|
async def health_check():
|
||||||
|
"""Health check endpoint."""
|
||||||
|
return {"status": "healthy"}
|
||||||
|
|
||||||
# Response models matching AdGuard spec
|
# Response models matching AdGuard spec
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user