mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-23 23:29:31 +01:00
Change default db pooling
This commit is contained in:
@@ -272,15 +272,13 @@ if "postgres://" in DATABASE_URL:
|
|||||||
|
|
||||||
DATABASE_SCHEMA = os.environ.get("DATABASE_SCHEMA", None)
|
DATABASE_SCHEMA = os.environ.get("DATABASE_SCHEMA", None)
|
||||||
|
|
||||||
DATABASE_POOL_SIZE = os.environ.get("DATABASE_POOL_SIZE", 0)
|
DATABASE_POOL_SIZE = os.environ.get("DATABASE_POOL_SIZE", None)
|
||||||
|
|
||||||
if DATABASE_POOL_SIZE == "":
|
if DATABASE_POOL_SIZE != None:
|
||||||
DATABASE_POOL_SIZE = 0
|
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
DATABASE_POOL_SIZE = int(DATABASE_POOL_SIZE)
|
DATABASE_POOL_SIZE = int(DATABASE_POOL_SIZE)
|
||||||
except Exception:
|
except Exception:
|
||||||
DATABASE_POOL_SIZE = 0
|
DATABASE_POOL_SIZE = None
|
||||||
|
|
||||||
DATABASE_POOL_MAX_OVERFLOW = os.environ.get("DATABASE_POOL_MAX_OVERFLOW", 0)
|
DATABASE_POOL_MAX_OVERFLOW = os.environ.get("DATABASE_POOL_MAX_OVERFLOW", 0)
|
||||||
|
|
||||||
|
|||||||
@@ -94,10 +94,14 @@ else:
|
|||||||
pool_pre_ping=True,
|
pool_pre_ping=True,
|
||||||
poolclass=QueuePool,
|
poolclass=QueuePool,
|
||||||
)
|
)
|
||||||
else:
|
elif DATABASE_POOL_SIZE == 0:
|
||||||
engine = create_engine(
|
engine = create_engine(
|
||||||
SQLALCHEMY_DATABASE_URL, pool_pre_ping=True, poolclass=NullPool
|
SQLALCHEMY_DATABASE_URL, pool_pre_ping=True, poolclass=NullPool
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
engine = create_engine(
|
||||||
|
SQLALCHEMY_DATABASE_URL, pool_pre_ping=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
SessionLocal = sessionmaker(
|
SessionLocal = sessionmaker(
|
||||||
|
|||||||
Reference in New Issue
Block a user