mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-26 07:50:56 +02:00
add postgres configuration (#2076)
This commit is contained in:
parent
5097c7f284
commit
509fa3a994
@ -129,6 +129,17 @@ POSTGRES_HOST = os.environ.get("POSTGRES_HOST") or "localhost"
|
|||||||
POSTGRES_PORT = os.environ.get("POSTGRES_PORT") or "5432"
|
POSTGRES_PORT = os.environ.get("POSTGRES_PORT") or "5432"
|
||||||
POSTGRES_DB = os.environ.get("POSTGRES_DB") or "postgres"
|
POSTGRES_DB = os.environ.get("POSTGRES_DB") or "postgres"
|
||||||
|
|
||||||
|
# defaults to False
|
||||||
|
POSTGRES_POOL_PRE_PING = os.environ.get("POSTGRES_POOL_PRE_PING", "").lower() == "true"
|
||||||
|
|
||||||
|
# recycle timeout in seconds
|
||||||
|
POSTGRES_POOL_RECYCLE_DEFAULT = 60 * 20 # 20 minutes
|
||||||
|
try:
|
||||||
|
POSTGRES_POOL_RECYCLE = int(
|
||||||
|
os.environ.get("POSTGRES_POOL_RECYCLE", POSTGRES_POOL_RECYCLE_DEFAULT)
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
POSTGRES_POOL_RECYCLE = POSTGRES_POOL_RECYCLE_DEFAULT
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# Connector Configs
|
# Connector Configs
|
||||||
|
@ -16,6 +16,8 @@ from sqlalchemy.orm import sessionmaker
|
|||||||
from danswer.configs.app_configs import POSTGRES_DB
|
from danswer.configs.app_configs import POSTGRES_DB
|
||||||
from danswer.configs.app_configs import POSTGRES_HOST
|
from danswer.configs.app_configs import POSTGRES_HOST
|
||||||
from danswer.configs.app_configs import POSTGRES_PASSWORD
|
from danswer.configs.app_configs import POSTGRES_PASSWORD
|
||||||
|
from danswer.configs.app_configs import POSTGRES_POOL_PRE_PING
|
||||||
|
from danswer.configs.app_configs import POSTGRES_POOL_RECYCLE
|
||||||
from danswer.configs.app_configs import POSTGRES_PORT
|
from danswer.configs.app_configs import POSTGRES_PORT
|
||||||
from danswer.configs.app_configs import POSTGRES_USER
|
from danswer.configs.app_configs import POSTGRES_USER
|
||||||
from danswer.configs.constants import POSTGRES_UNKNOWN_APP_NAME
|
from danswer.configs.constants import POSTGRES_UNKNOWN_APP_NAME
|
||||||
@ -77,7 +79,13 @@ def get_sqlalchemy_engine() -> Engine:
|
|||||||
connection_string = build_connection_string(
|
connection_string = build_connection_string(
|
||||||
db_api=SYNC_DB_API, app_name=POSTGRES_APP_NAME + "_sync"
|
db_api=SYNC_DB_API, app_name=POSTGRES_APP_NAME + "_sync"
|
||||||
)
|
)
|
||||||
_SYNC_ENGINE = create_engine(connection_string, pool_size=40, max_overflow=10)
|
_SYNC_ENGINE = create_engine(
|
||||||
|
connection_string,
|
||||||
|
pool_size=40,
|
||||||
|
max_overflow=10,
|
||||||
|
pool_pre_ping=POSTGRES_POOL_PRE_PING,
|
||||||
|
pool_recycle=POSTGRES_POOL_RECYCLE,
|
||||||
|
)
|
||||||
return _SYNC_ENGINE
|
return _SYNC_ENGINE
|
||||||
|
|
||||||
|
|
||||||
@ -94,6 +102,8 @@ def get_sqlalchemy_async_engine() -> AsyncEngine:
|
|||||||
},
|
},
|
||||||
pool_size=40,
|
pool_size=40,
|
||||||
max_overflow=10,
|
max_overflow=10,
|
||||||
|
pool_pre_ping=POSTGRES_POOL_PRE_PING,
|
||||||
|
pool_recycle=POSTGRES_POOL_RECYCLE,
|
||||||
)
|
)
|
||||||
return _ASYNC_ENGINE
|
return _ASYNC_ENGINE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user