diff --git a/ctrl/workers.py b/ctrl/workers.py
index 004c1ed..3dea679 100644
--- a/ctrl/workers.py
+++ b/ctrl/workers.py
@@ -4,8 +4,16 @@ import requests
def parse_worker(spec):
- """'host:port' -> {'url': 'http://host:port', 'host': host, 'port': port}."""
- host, _, port = spec.strip().rpartition(":")
+ """'host:port' -> {'url': 'http://host:port', 'host': host, 'port': port}.
+
+ Tolerates an optional http:// or https:// scheme prefix.
+ """
+ s = spec.strip()
+ for scheme in ("http://", "https://"):
+ if s.lower().startswith(scheme):
+ s = s[len(scheme):]
+ break
+ host, _, port = s.rpartition(":")
if not host or not port.isdigit():
raise ValueError(f"Invalid worker spec: {spec!r} (expected host:port)")
return {"url": f"http://{host}:{port}", "host": host, "port": int(port)}
@@ -22,7 +30,7 @@ def configured_workers():
return out
-def probe_worker(url, timeout=None):
+def probe_worker(url, host=None, port=None, timeout=None):
"""Return a normalized worker status dict, or None if unreachable."""
timeout = timeout or settings.WORKER_STATUS_TIMEOUT
try:
@@ -34,13 +42,17 @@ def probe_worker(url, timeout=None):
info["url"] = url
info["online"] = True
+ if host is not None:
+ info["host"] = host
+ if port is not None:
+ info["port"] = port
return info
def probe_all():
workers = []
for w in configured_workers():
- status = probe_worker(w["url"])
+ status = probe_worker(w["url"], host=w["host"], port=w["port"])
if status:
workers.append(status)
else: