dont silently crash when database connection fails
This commit is contained in:
parent
934ee9b4fa
commit
25715f5aee
@ -12,11 +12,18 @@ from capsulflask.shared import my_exec_info_message
|
|||||||
|
|
||||||
def init_app(app, is_running_server):
|
def init_app(app, is_running_server):
|
||||||
|
|
||||||
app.config['PSYCOPG2_CONNECTION_POOL'] = psycopg2.pool.SimpleConnectionPool(
|
try:
|
||||||
1,
|
app.config['PSYCOPG2_CONNECTION_POOL'] = psycopg2.pool.SimpleConnectionPool(
|
||||||
20,
|
1,
|
||||||
app.config['POSTGRES_CONNECTION_PARAMETERS']
|
20,
|
||||||
)
|
app.config['POSTGRES_CONNECTION_PARAMETERS']
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
app.logger.error(f"""
|
||||||
|
error was thrown when connecting to postgres database:
|
||||||
|
{my_exec_info_message(sys.exc_info())}"""
|
||||||
|
)
|
||||||
|
raise
|
||||||
|
|
||||||
# tell the app to clean up the DB connection when shutting down.
|
# tell the app to clean up the DB connection when shutting down.
|
||||||
app.teardown_appcontext(close_db)
|
app.teardown_appcontext(close_db)
|
||||||
|
Loading…
Reference in New Issue
Block a user