remove hardcoded config file path
This commit is contained in:
@@ -80,20 +80,18 @@ class Backpressure:
|
|||||||
self.time_window = config.getint('CleverMicro-AMQ', self.PREFIX + 'time-window', fallback=3000)
|
self.time_window = config.getint('CleverMicro-AMQ', self.PREFIX + 'time-window', fallback=3000)
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_PROPERTIES_FILE = '/app/amqp/config/application.properties'
|
|
||||||
|
|
||||||
|
|
||||||
class AMQConfiguration:
|
class AMQConfiguration:
|
||||||
"""
|
"""
|
||||||
Top level configuration context holder / object
|
Top level configuration context holder / object
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self, config_file_name: str = None):
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
# Read the application.properties file
|
# Read the application.properties file
|
||||||
if os.path.exists(DEFAULT_PROPERTIES_FILE):
|
if os.path.exists(config_file_name):
|
||||||
config.read(DEFAULT_PROPERTIES_FILE)
|
config.read(config_file_name)
|
||||||
else:
|
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
|
# Override values with environment variables
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ class AMQService:
|
|||||||
self.amq_service_message_handler.outstanding.pop(message_id, None)
|
self.amq_service_message_handler.outstanding.pop(message_id, None)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
# if __name__ == "__main__":
|
||||||
amq_configuration: AMQConfiguration = AMQConfiguration()
|
# amq_configuration: AMQConfiguration = AMQConfiguration('../config/application.properties.local')
|
||||||
# amq_service: AMQService = AMQService(amq_configuration, CleverSwarmAmqpAdapter(amq_configuration))
|
# amq_service: AMQService = AMQService(amq_configuration, CleverSwarmAmqpAdapter(amq_configuration))
|
||||||
# amq_service.rabbit_mq_consumer.channel.start_consuming()
|
# amq_service.rabbit_mq_consumer.channel.start_consuming()
|
||||||
# amq_service.consumer_thread.cancel()
|
# amq_service.consumer_thread.cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user