From f0cb1925ec13898cd297dc5c1bb17eb505806e7f Mon Sep 17 00:00:00 2001 From: Dewaldt Huysamen Date: Sat, 31 Jan 2026 10:27:57 +0200 Subject: [PATCH] fix(hindsight-embed): respect HINDSIGHT_API_DATABASE_URL if already set (#262) The daemon_client unconditionally overwrites HINDSIGHT_API_DATABASE_URL with pg0://hindsight-embed, preventing users from using an external PostgreSQL instance. This is a problem for VPS deployments running as root, where pg0's embedded PostgreSQL fails with 'initdb: cannot be run as root'. This change checks if the env var is already set before defaulting to pg0, allowing users to point to an external PostgreSQL while preserving the default embedded behavior. Fixes #261 --- hindsight-embed/hindsight_embed/daemon_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hindsight-embed/hindsight_embed/daemon_client.py b/hindsight-embed/hindsight_embed/daemon_client.py index 85e16a5d..27e2f6dc 100644 --- a/hindsight-embed/hindsight_embed/daemon_client.py +++ b/hindsight-embed/hindsight_embed/daemon_client.py @@ -76,7 +76,10 @@ def _start_daemon(config: dict) -> bool: env["HINDSIGHT_API_LLM_MODEL"] = config["llm_model"] # Use single shared pg0 database for all banks (banks are isolated within the database) - env["HINDSIGHT_API_DATABASE_URL"] = "pg0://hindsight-embed" + # Allow override via HINDSIGHT_API_DATABASE_URL for external PostgreSQL + # (e.g. when running as root where embedded pg0 cannot use initdb) + if "HINDSIGHT_API_DATABASE_URL" not in env: + env["HINDSIGHT_API_DATABASE_URL"] = "pg0://hindsight-embed" env["HINDSIGHT_API_LOG_LEVEL"] = "info" # Get idle timeout from environment or use default