dont silently crash when database connection fails

This commit is contained in:
forest 2021-10-05 10:50:31 -05:00
parent 934ee9b4fa
commit 25715f5aee

View File

@ -12,11 +12,18 @@ from capsulflask.shared import my_exec_info_message
def init_app(app, is_running_server):
try:
app.config['PSYCOPG2_CONNECTION_POOL'] = psycopg2.pool.SimpleConnectionPool(
1,
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.
app.teardown_appcontext(close_db)