File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from sqlalchemy import create_engine
22from sqlalchemy .ext .declarative import declarative_base
33from sqlalchemy .orm import sessionmaker
4+ from sqlalchemy .pool import NullPool
45import os
56import sys
7+ import psycopg2
68
7- # Force redeploy - testing SSL fix
89DATABASE_URL = os .environ .get ("DATABASE_URL" )
910sys .stderr .write (
10- f"[DB DEBUG] DATABASE_URL: { DATABASE_URL [:100 ] if DATABASE_URL else 'None' } \n "
11+ f"[DB DEBUG] DATABASE_URL: { DATABASE_URL [:80 ] if DATABASE_URL else 'None' } \n "
1112)
1213sys .stderr .write (f"[DB DEBUG] DATA_DIR: { os .environ .get ('DATA_DIR' , 'Not set' )} \n " )
13- sys .stderr .write (f"[DB DEBUG] Python version: { sys .version } \n " )
1414
15- # INTENTIONAL ERROR TO TEST IF CODE IS BEING USED
1615RAILWAY_TEST_VARIABLE = "THIS_SHOULD_APPEAR_IN_LOGS_IF_CODE_IS_LOADED"
1716
1817if DATABASE_URL :
1918 if DATABASE_URL .startswith ("postgresql://" ):
20- sys .stderr .write (
21- f"[DB DEBUG] Using DATABASE_URL: { DATABASE_URL [:80 ]} ...\n "
22- )
19+ sys .stderr .write (f"[DB DEBUG] Using PostgreSQL with NullPool\n " )
2320 engine = create_engine (
2421 DATABASE_URL ,
25- pool_pre_ping = True ,
26- pool_recycle = 300 ,
22+ poolclass = NullPool ,
2723 connect_args = {
2824 "connect_timeout" : 10 ,
29- "sslmode" : "require"
30- }
25+ "sslmode" : "require" ,
26+ "keepalives" : 1 ,
27+ "keepalives_idle" : 30 ,
28+ "keepalives_interval" : 10 ,
29+ "keepalives_count" : 5 ,
30+ },
3131 )
3232 else :
3333 engine = create_engine (DATABASE_URL )
34- else :
35- engine = create_engine (DATABASE_URL )
3634else :
3735 BASE_DIR = os .path .dirname (os .path .abspath (__file__ ))
3836 DATA_DIR = os .environ .get ("DATA_DIR" , "/tmp" )
You can’t perform that action at this time.
0 commit comments