Add support for custom health check paths in healthcheck function
This commit is contained in:
@@ -45,6 +45,7 @@ def healthcheck():
|
|||||||
host_attr = svc.get('host')
|
host_attr = svc.get('host')
|
||||||
proto_attr = svc.get('proto') or proto
|
proto_attr = svc.get('proto') or proto
|
||||||
port_attr = svc.get('port') or port
|
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
|
# 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
|
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:
|
if not host or not port:
|
||||||
return jsonify({'error': 'missing parameters, expected host and port or id'}), 400
|
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:
|
try:
|
||||||
# Use HEAD to do a lightweight check
|
# Use HEAD to do a lightweight check
|
||||||
|
|||||||
Reference in New Issue
Block a user