Fix: volume mount tilde expansion, PR counting bug, startup diagnostics
- docker-compose: use ${HOME}/.timmy instead of ~/.timmy (Docker doesn't expand tilde)
- exporter: start HTTP server BEFORE first collection (so /metrics is always available)
- exporter: add startup diagnostics (data dir check, Gitea reachability)
- exporter: fix agent PR counting that would crash on _value access
This commit is contained in:
@@ -44,8 +44,8 @@ services:
|
||||
ports:
|
||||
- "9101:9101"
|
||||
volumes:
|
||||
- ${TIMMY_HOME:-~/.timmy}:/data/timmy:ro
|
||||
- ${HERMES_HOME:-~/.hermes}:/data/hermes:ro
|
||||
- ${TIMMY_HOME:-${HOME}/.timmy}:/data/timmy:ro
|
||||
- ${HERMES_HOME:-${HOME}/.hermes}:/data/hermes:ro
|
||||
environment:
|
||||
- GITEA_URL=http://143.198.27.163:3000
|
||||
- GITEA_TOKEN=${GITEA_TOKEN:-130c3811bf4bae84a724cc165d677573d0f89636}
|
||||
|
||||
@@ -168,6 +168,7 @@ def collect_gitea_metrics():
|
||||
since_24h = (datetime.now(timezone.utc) - timedelta(hours=24)).isoformat()
|
||||
agents = ["claude", "gemini", "kimi", "grok", "perplexity", "Timmy", "Rockachopa"]
|
||||
agent_commit_counts = {a: 0 for a in agents}
|
||||
agent_pr_counts = {a: 0 for a in agents}
|
||||
|
||||
gitea_alive = False
|
||||
|
||||
@@ -203,15 +204,13 @@ def collect_gitea_metrics():
|
||||
author = pr.get("user", {}).get("login", "")
|
||||
for agent in agents:
|
||||
if agent.lower() == author.lower():
|
||||
agent_prs_open.labels(agent=agent).set(
|
||||
agent_prs_open.labels(agent=agent)._value._value + 1
|
||||
if hasattr(agent_prs_open.labels(agent=agent), '_value')
|
||||
else 1
|
||||
)
|
||||
agent_pr_counts[agent] = agent_pr_counts.get(agent, 0) + 1
|
||||
|
||||
# Set agent commit gauges
|
||||
for agent, count in agent_commit_counts.items():
|
||||
agent_commits_24h.labels(agent=agent).set(count)
|
||||
for agent, count in agent_pr_counts.items():
|
||||
agent_prs_open.labels(agent=agent).set(count)
|
||||
|
||||
gitea_up_gauge.set(1 if gitea_alive else 0)
|
||||
return gitea_alive
|
||||
@@ -513,6 +512,29 @@ if __name__ == "__main__":
|
||||
print(f" Timmy data: {TIMMY_DATA}")
|
||||
print(f" Hermes data: {HERMES_DATA}")
|
||||
|
||||
# Diagnostic: check what data is actually accessible
|
||||
print("\n📂 Data directory check:")
|
||||
for label, d in [("TIMMY_DATA", TIMMY_DATA), ("HERMES_DATA", HERMES_DATA)]:
|
||||
exists = d.exists()
|
||||
print(f" {label} ({d}): {'EXISTS' if exists else 'MISSING'}")
|
||||
if exists:
|
||||
contents = list(d.iterdir())[:10]
|
||||
for c in contents:
|
||||
print(f" {'dir ' if c.is_dir() else 'file'} {c.name}")
|
||||
|
||||
print(f"\n🌐 Gitea check:")
|
||||
try:
|
||||
r = requests.get(f"{GITEA_URL}/api/v1/repos/Timmy_Foundation/the-nexus",
|
||||
headers={"Authorization": f"token {GITEA_TOKEN}"},
|
||||
timeout=5)
|
||||
print(f" Gitea API: {r.status_code} ({'OK' if r.status_code == 200 else 'FAIL'})")
|
||||
except Exception as e:
|
||||
print(f" Gitea API: UNREACHABLE ({e})")
|
||||
|
||||
# Start Prometheus HTTP server FIRST so /metrics is always available
|
||||
start_http_server(9101)
|
||||
print("\n🟢 Exporter ready — http://localhost:9101/metrics")
|
||||
|
||||
# Initial collection
|
||||
collect_all()
|
||||
|
||||
@@ -520,10 +542,6 @@ if __name__ == "__main__":
|
||||
t = threading.Thread(target=collection_loop, daemon=True)
|
||||
t.start()
|
||||
|
||||
# Start Prometheus HTTP server
|
||||
start_http_server(9101)
|
||||
print("🟢 Exporter ready — http://localhost:9101/metrics")
|
||||
|
||||
# Block forever
|
||||
while True:
|
||||
time.sleep(3600)
|
||||
|
||||
Reference in New Issue
Block a user