From e7d3e0153a407d63cdea8f05ef3245cd83edda71 Mon Sep 17 00:00:00 2001 From: sameer0422 <168476827+sameer0422@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:20:59 -0700 Subject: [PATCH] 18254 - AUTH - Backend - Environment variables cleanup (#2958) --- auth-api/src/auth_api/config.py | 5 ++++- auth-api/wsgi.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/auth-api/src/auth_api/config.py b/auth-api/src/auth_api/config.py index bd5a71c256..f5ea7f85df 100644 --- a/auth-api/src/auth_api/config.py +++ b/auth-api/src/auth_api/config.py @@ -74,7 +74,10 @@ class _Config: # pylint: disable=too-few-public-methods DB_NAME = os.getenv('DATABASE_NAME', '') DB_HOST = os.getenv('DATABASE_HOST', '') DB_PORT = os.getenv('DATABASE_PORT', '5432') - SQLALCHEMY_DATABASE_URI = f'postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}' + if DB_UNIX_SOCKET := os.getenv('DATABASE_UNIX_SOCKET', None): + SQLALCHEMY_DATABASE_URI = f'postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?host={DB_UNIX_SOCKET}' + else: + SQLALCHEMY_DATABASE_URI = f'postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}' SQLALCHEMY_ECHO = False SQLALCHEMY_TRACK_MODIFICATIONS = False diff --git a/auth-api/wsgi.py b/auth-api/wsgi.py index 612a6e3705..d841635d28 100644 --- a/auth-api/wsgi.py +++ b/auth-api/wsgi.py @@ -13,6 +13,7 @@ # limitations under the License. """Provides the WSGI entry point for running the application """ +import os from auth_api import create_app @@ -20,4 +21,5 @@ app = create_app() # pylint: disable=invalid-name if __name__ == "__main__": - app.run() + server_port = os.environ.get('PORT', '8080') + app.run(debug=False, port=server_port, host='0.0.0.0')