feat(analyzer): load config using shared helpers

- make rabbitmq config optional
This commit is contained in:
jo 2022-01-18 06:37:47 +01:00 committed by Kyle Robbertze
parent b527c2704d
commit 35d38df9d3
5 changed files with 20 additions and 42 deletions

View file

@ -6,13 +6,12 @@ from libretime_shared.app import AbstractApp
from libretime_shared.cli import cli_config_options, cli_logging_options
from libretime_shared.config import DEFAULT_ENV_PREFIX
from .config_file import read_config_file
from .config import Config
from .message_listener import MessageListener
from .status_reporter import StatusReporter
VERSION = "1.0"
DEFAULT_LIBRETIME_CONFIG_FILEPATH = Path("/etc/airtime/airtime.conf")
DEFAULT_RETRY_QUEUE_FILEPATH = Path("retry_queue")
@ -38,8 +37,7 @@ def cli(
Analyzer(
log_level=log_level,
log_filepath=log_filepath,
# Handle default until the config file can be optional
config_filepath=config_filepath or DEFAULT_LIBRETIME_CONFIG_FILEPATH,
config_filepath=config_filepath,
retry_queue_filepath=retry_queue_filepath,
)
@ -56,14 +54,13 @@ class Analyzer(AbstractApp):
):
super().__init__(**kwargs)
# Read our rmq config file
rmq_config = read_config_file(config_filepath)
config = Config(filepath=config_filepath)
# Start up the StatusReporter process
StatusReporter.start_thread(retry_queue_filepath)
# Start listening for RabbitMQ messages telling us about newly
# uploaded files. This blocks until we receive a shutdown signal.
self._msg_listener = MessageListener(rmq_config)
self._msg_listener = MessageListener(config.rabbitmq)
StatusReporter.stop_thread()