From 92bc28ac058346b674bb1395dc263c8dbcf29613 Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Fri, 1 Mar 2024 23:18:11 -0500 Subject: [PATCH] improve state handling & logging --- hyperglass/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hyperglass/main.py b/hyperglass/main.py index 3002f3a..50a2110 100644 --- a/hyperglass/main.py +++ b/hyperglass/main.py @@ -118,14 +118,15 @@ def when_ready(server: "Arbiter") -> None: def on_exit(_: t.Any) -> None: """Gunicorn shutdown tasks.""" - log.critical("Stopping hyperglass {}", __version__) - state = use_state() - if not Settings.dev_mode: - state.clear() + state.clear() + + log.info("Cleared hyperglass state") unregister_all_plugins() + log.critical("Stopping hyperglass {}", __version__) + class HyperglassWSGI(BaseApplication): """Custom gunicorn app.""" @@ -185,6 +186,9 @@ def run(_workers: int = None): try: log.debug("System settings: {!r}", Settings) + state = use_state() + state.clear() + init_user_config() workers = 1 if Settings.debug else cpu_count(2)