Make port configurable (default 5100)

- Port now set via config.json "port" field
- Aggregator reads PORT from environment variable
- Updated all docs and scripts to use port 5100

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-02 23:24:24 -06:00
parent 5783a52cfa
commit 3e99780e87
6 changed files with 25 additions and 17 deletions

17
kao.py
View File

@@ -89,11 +89,17 @@ class KaoManager:
break
print(f"[{name}] {line.rstrip()}")
def get_aggregator_url(self):
"""Get aggregator URL from config port."""
port = self.config.get("port", 5100)
return f"http://localhost:{port}"
def start_aggregator(self):
"""Start the aggregator service."""
agg_config = self.config.get("aggregator", {})
script = agg_config.get("script", "aggregator.py")
env = agg_config.get("env", {})
env["PORT"] = str(self.config.get("port", 5100))
process = self.start_process("aggregator", script, env)
if process:
@@ -102,13 +108,12 @@ class KaoManager:
"config": {"name": "aggregator", "script": script, "env": env},
}
# Wait for aggregator to be ready
url = self.config.get("aggregator_url", "http://localhost:5000")
return self.wait_for_aggregator(url)
return self.wait_for_aggregator(self.get_aggregator_url())
return False
def start_detectors(self):
"""Start all enabled detectors."""
url = self.config.get("aggregator_url", "http://localhost:5000")
url = self.get_aggregator_url()
for detector in self.config.get("detectors", []):
if not detector.get("enabled", True):
@@ -140,7 +145,7 @@ class KaoManager:
if self.running:
config = info["config"]
env = {"AGGREGATOR_URL": self.config.get("aggregator_url", "http://localhost:5000")}
env = {"AGGREGATOR_URL": self.get_aggregator_url()}
env.update(config.get("env", {}))
new_process = self.start_process(name, config["script"], env)
@@ -186,7 +191,7 @@ class KaoManager:
print(" Kao")
print("=" * 50)
print(f"Config: {self.config_path}")
print(f"Aggregator URL: {self.config.get('aggregator_url')}")
print(f"Port: {self.config.get('port', 5100)}")
print()
enabled = [d["name"] for d in self.config.get("detectors", []) if d.get("enabled", True)]
@@ -211,7 +216,7 @@ class KaoManager:
print()
print("=" * 50)
print(f" UI available at: {self.config.get('aggregator_url')}")
print(f" UI available at: {self.get_aggregator_url()}")
print("=" * 50)
print()