diff --git a/passbook/lib/config.py b/passbook/lib/config.py index 1158673aa..a8db9bab8 100644 --- a/passbook/lib/config.py +++ b/passbook/lib/config.py @@ -8,6 +8,7 @@ from typing import Any import yaml from django.conf import ImproperlyConfigured +from django.utils.autoreload import autoreload_started SEARCH_PATHS = [ 'passbook/lib/default.yml', @@ -21,6 +22,8 @@ ENVIRONMENT = os.getenv('PASSBOOK_ENV', 'local') class ConfigLoader: """Search through SEARCH_PATHS and load configuration""" + loaded_file = [] + __config = {} __context_default = None __sub_dicts = [] @@ -69,6 +72,8 @@ class ConfigLoader: with open(path) as file: try: self.update(self.__config, yaml.safe_load(file)) + LOGGER.debug("Loaded %s", path) + self.loaded_file.append(path) except yaml.YAMLError as exc: raise ImproperlyConfigured from exc except PermissionError as exc: @@ -126,3 +131,10 @@ class ConfigLoader: CONFIG = ConfigLoader() + +# pylint: disable=unused-argument +def signal_handler(sender, **kwargs): + """Add all loaded config files to autoreload watcher""" + for path in CONFIG.loaded_file: + sender.watch_file(path) +autoreload_started.connect(signal_handler) diff --git a/passbook/lib/default.yml b/passbook/lib/default.yml index d51dd7d70..7e11d089c 100644 --- a/passbook/lib/default.yml +++ b/passbook/lib/default.yml @@ -35,6 +35,8 @@ redis: localhost/0 error_report_enabled: true secret_key: 9$@r!d^1^jrn#fk#1#@ks#9&i$^s#1)_13%$rwjrhd=e8jfi_s +domains: + - passbook.local primary_domain: 'localhost' passbook: