diff --git a/Script/CastorScript.py b/Script/CastorScript.py index 1b8d8dd98e388f2b13d51f940f409ed4e607aa0c..b42d2e339aee4df7893f917c51cc1cd5bc3ec195 100644 --- a/Script/CastorScript.py +++ b/Script/CastorScript.py @@ -115,7 +115,6 @@ if config.EmailLogList: LogConfig.enable_mail_logging(config) logger = LogConfig.enable_file_logging("main", "main.log", config) -dblogger = LogConfig.enable_file_logging("database", "database.log", config) # Load filename parser try: @@ -166,9 +165,11 @@ signal.signal(signal.SIGINT, main_exit) logger.info(thread_id_string()) # Connect to database -db = None -db = checkDB(db, logger, dblogger, filename_parser, config) -db_last_connection_time = time() +if config.DBURL: + dblogger = LogConfig.enable_file_logging("database", "database.log", config) + db = None + db = checkDB(db, logger, dblogger, filename_parser, config) + db_last_connection_time = time() # Setup Kerberos if needed if config.Keytab: @@ -193,19 +194,20 @@ if config.DdmMonitoringEnabled: while not exit_event.is_set(): - logger.debug('checking DB connection') - db = checkDB(db, logger, dblogger, filename_parser, config) - - # Always keep a fresh connection - if db and (time() - db_last_connection_time) > config.DBReconnectTimeout: - logger.info('refreshing database connection') - with db_lock: - try: - db.Reconnect() - except Exception as ex: - logger.error('error connecting to DB: %s', str(ex)) - db = None - db_last_connection_time = time() + if config.DBURL: + logger.debug('checking DB connection') + db = checkDB(db, logger, dblogger, filename_parser, config) + + # Always keep a fresh connection + if db and (time() - db_last_connection_time) > config.DBReconnectTimeout: + logger.info('refreshing database connection') + with db_lock: + try: + db.Reconnect() + except Exception as ex: + logger.error('error connecting to DB: %s', str(ex)) + db = None + db_last_connection_time = time() # Update KRB token, if needed: if config.Keytab: