Spaces:
Running
Running
deploy from github actions
Browse files- app/database.py +6 -1
app/database.py
CHANGED
|
@@ -12,6 +12,11 @@ load_dotenv()
|
|
| 12 |
DATABASE_URL = os.getenv("DATABASE_URL")
|
| 13 |
|
| 14 |
if DATABASE_URL:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
connect_args = {}
|
| 16 |
if DATABASE_URL.startswith("postgresql"):
|
| 17 |
connect_args = {
|
|
@@ -27,7 +32,7 @@ if DATABASE_URL:
|
|
| 27 |
pool_size=20,
|
| 28 |
max_overflow=40,
|
| 29 |
pool_timeout=10,
|
| 30 |
-
pool_recycle=
|
| 31 |
pool_pre_ping=True,
|
| 32 |
connect_args=connect_args
|
| 33 |
)
|
|
|
|
| 12 |
DATABASE_URL = os.getenv("DATABASE_URL")
|
| 13 |
|
| 14 |
if DATABASE_URL:
|
| 15 |
+
# Asegurar uso de Session Mode (puerto 5432) en lugar de Transaction Mode (6543)
|
| 16 |
+
# para evitar que PgBouncer mate sockets SSL de forma inesperada entre transacciones
|
| 17 |
+
if ":6543" in DATABASE_URL:
|
| 18 |
+
DATABASE_URL = DATABASE_URL.replace(":6543", ":5432")
|
| 19 |
+
|
| 20 |
connect_args = {}
|
| 21 |
if DATABASE_URL.startswith("postgresql"):
|
| 22 |
connect_args = {
|
|
|
|
| 32 |
pool_size=20,
|
| 33 |
max_overflow=40,
|
| 34 |
pool_timeout=10,
|
| 35 |
+
pool_recycle=300,
|
| 36 |
pool_pre_ping=True,
|
| 37 |
connect_args=connect_args
|
| 38 |
)
|