From a803b9e6adba76b8d34d8a6aaec2b0c52966f3d3 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Fri, 27 Oct 2023 09:57:10 +0200 Subject: [PATCH] TMSS-1996: startup fix. This service needs to check both the django orm setup, and the rest client --- .../services/report_refresh/lib/report_refresh.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SAS/TMSS/backend/services/report_refresh/lib/report_refresh.py b/SAS/TMSS/backend/services/report_refresh/lib/report_refresh.py index 6d84885694c..12aafe53876 100644 --- a/SAS/TMSS/backend/services/report_refresh/lib/report_refresh.py +++ b/SAS/TMSS/backend/services/report_refresh/lib/report_refresh.py @@ -78,11 +78,19 @@ def main(): group = OptionGroup(parser, 'Django options') parser.add_option_group(group) - group.add_option('-C', '--credentials', dest='dbcredentials', type='string', default=os.environ.get('TMSS_DBCREDENTIALS', 'TMSSClient'), help='django rest api dbcredentials name, default: %default') + group.add_option('-R', '--tmss_client_credentials_id', dest='tmss_client_credentials_id', type='string', default='TMSSClient', help='TMSS django REST API credentials name, default: %default') + group.add_option('-C', '--credentials', dest='dbcredentials', type='string', default=os.environ.get('TMSS_DBCREDENTIALS', 'TMSS'), help='django dbcredentials name, default: %default') (options, args) = parser.parse_args() - with create_service(options.exchange, options.broker, options.dbcredentials): + # check TMSS is up and running via the client + TMSSsession.check_connection_and_exit_on_error(options.tmss_client_credentials_id) + + # setup/check the django ORM as well + from lofar.sas.tmss.tmss import setup_and_check_tmss_django_database_connection_and_exit_on_error + setup_and_check_tmss_django_database_connection_and_exit_on_error(options.dbcredentials) + + with create_service(options.exchange, options.broker, options.tmss_client_credentials_id): waitForInterrupt() if __name__ == '__main__': -- GitLab