Add support for custom health check paths in healthcheck function

This commit is contained in:
MayaChat
2025-11-24 12:46:06 -05:00
parent 6d5aab17a8
commit 5f8688fb70

View File

@@ -45,6 +45,7 @@ def healthcheck():
host_attr = svc.get('host')
proto_attr = svc.get('proto') or proto
port_attr = svc.get('port') or port
health_path = svc.get('health-path', '') # Custom health check path (e.g., /api/health, /ping)
# prefer local-ip if present
target_host = local_ip or root_tailscale or (host_attr.split(':')[0] if host_attr and ':' in host_attr else None) or host
@@ -60,7 +61,9 @@ def healthcheck():
if not host or not port:
return jsonify({'error': 'missing parameters, expected host and port or id'}), 400
url = f"{proto}://{host}:{port}"
# Build URL with optional custom health path
health_path = health_path if 'health_path' in locals() else ''
url = f"{proto}://{host}:{port}{health_path}"
try:
# Use HEAD to do a lightweight check