From afd6590360c86fb5ae93f82b80edd75ee5ee9271 Mon Sep 17 00:00:00 2001 From: gac-x12sa Date: Wed, 11 Jun 2025 12:51:02 +0200 Subject: [PATCH] fix(pre-startup): update pre_startup get_config for test, production and local usage --- .../bec_ipython_client/startup/pre_startup.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/startup/pre_startup.py b/csaxs_bec/bec_ipython_client/startup/pre_startup.py index c9e6274..1446114 100644 --- a/csaxs_bec/bec_ipython_client/startup/pre_startup.py +++ b/csaxs_bec/bec_ipython_client/startup/pre_startup.py @@ -2,7 +2,9 @@ Pre-startup script for BEC client. This script is executed before the BEC client is started. It can be used to add additional command line arguments. """ - +import os +import csaxs_bec +from bec_lib.service_config import ServiceConfig def extend_command_line_args(parser): """ @@ -14,8 +16,14 @@ def extend_command_line_args(parser): return parser -# def get_config() -> ServiceConfig: -# """ -# Create and return the service configuration. -# """ -# return ServiceConfig(redis={"host": "localhost", "port": 6379}) +def get_config() -> ServiceConfig: + """ + Create and return the service configuration. + """ + path = os.path.dirname(csaxs_bec.__file__) + if path.startswith('/data/test/x12sa-test-bec/production'): + return ServiceConfig(redis={"host": "x12sa-bec-001", "port": 6379}) + elif path.startswith('/data/test/x12sa-test-bec/test'): + return ServiceConfig(redis={"host": "x12sa-bec-002", "port": 6379}) + else: + return ServiceConfig(redis={"host": "localhost", "port": 6379})