diff --git a/config.ini.example b/config.ini.example index 5ff7cfbb..c6edcb60 100644 --- a/config.ini.example +++ b/config.ini.example @@ -20,3 +20,4 @@ user = your_username password = your_password database = your_database workspace = default # 可选,默认为default +max_connections = 12 \ No newline at end of file diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 46232ceb..02bcdeb2 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -55,7 +55,7 @@ class PostgreSQLDB: self.password = config.get("password", None) self.database = config.get("database", "postgres") self.workspace = config.get("workspace", "default") - self.max = 12 + self.max = int(config.get("max_connections", 12)) self.increment = 1 self.pool: Pool | None = None @@ -312,6 +312,10 @@ class ClientManager: "POSTGRES_WORKSPACE", config.get("postgres", "workspace", fallback="default"), ), + "max_connections": os.environ.get( + "POSTGRES_MAX_CONNECTIONS", + config.get("postgres", "max_connections", fallback=12), + ), } @classmethod