remove hardcoded config file path

This commit is contained in:
Stanislav Hejny
2025-02-28 00:10:18 +00:00
parent aaf1c77e72
commit aaa2895cbc
2 changed files with 7 additions and 9 deletions
+5 -7
View File
@@ -80,20 +80,18 @@ class Backpressure:
self.time_window = config.getint('CleverMicro-AMQ', self.PREFIX + 'time-window', fallback=3000)
DEFAULT_PROPERTIES_FILE = '/app/amqp/config/application.properties'
class AMQConfiguration:
"""
Top level configuration context holder / object
"""
def __init__(self):
def __init__(self, config_file_name: str = None):
config = configparser.ConfigParser()
# Read the application.properties file
if os.path.exists(DEFAULT_PROPERTIES_FILE):
config.read(DEFAULT_PROPERTIES_FILE)
if os.path.exists(config_file_name):
config.read(config_file_name)
else:
config.read('../config/application.properties.local')
print(f" [E] Configuration file not found: {config_file_name}")
print(" [W] Defaulting to preset values, which will likely be wrong, causing errors.")
# Override values with environment variables
for section in config.sections():
+2 -2
View File
@@ -84,8 +84,8 @@ class AMQService:
self.amq_service_message_handler.outstanding.pop(message_id, None)
if __name__ == "__main__":
amq_configuration: AMQConfiguration = AMQConfiguration()
# if __name__ == "__main__":
# amq_configuration: AMQConfiguration = AMQConfiguration('../config/application.properties.local')
# amq_service: AMQService = AMQService(amq_configuration, CleverSwarmAmqpAdapter(amq_configuration))
# amq_service.rabbit_mq_consumer.channel.start_consuming()
# amq_service.consumer_thread.cancel()