fix(mcp,db,systemd,logrotate): move telemetry DB to /var/lib/hyperstitionstud.io/api-telemetry.db via StateDirectory=hyperstitionstud.io and catch sqlite3.Error (v2.0.22)

This commit is contained in:
Hermes Agent committed 2026-11-30 07:55:22 +00:00
1 parent 95a5fc8618
commit 9716a0ab61
24 files changed
+140 -84

No files matched your search

+25 -1
View File
@@ -214,6 +214,23 @@ def get_default_telemetry_db_path() -> Path:
env_p = os.environ.get("HYPERSTITION_TELEMETRY_DB_PATH")
if env_p:
return Path(env_p)
state_dir = Path("/var/lib/hyperstitionstud.io")
if state_dir.is_dir() and os.access(state_dir, os.W_OK):
return state_dir / "api-telemetry.db"
if state_dir.parent.is_dir() and os.access(state_dir.parent, os.W_OK):
try:
state_dir.mkdir(parents=True, exist_ok=True)
if os.access(state_dir, os.W_OK):
return state_dir / "api-telemetry.db"
except OSError:
pass
try:
cache_dir = Path.home() / ".cache" / "hyperstitionstud.io"
cache_dir.mkdir(parents=True, exist_ok=True)
if os.access(cache_dir, os.W_OK):
return cache_dir / "api-telemetry.db"
except OSError:
pass
return Path("/tmp/hyperstition-api-telemetry.db")
@@ -994,8 +1011,15 @@ def record_api_telemetry(
raise
finally:
conn.close()
for suf in ("", "-wal", "-shm"):
cand = Path(f"{t_path}{suf}")
if cand.exists():
try:
os.chmod(cand, 0o666)
except OSError:
pass
return {"ok": True, "db_path": str(t_path)}
except OSError as exc:
except Exception as exc:
return {"ok": False, "error": str(exc)}