improve state handling & logging

This commit is contained in:
thatmattlove 2024-03-01 23:18:11 -05:00
parent 9e6e0d55ee
commit 92bc28ac05

View file

@ -118,14 +118,15 @@ def when_ready(server: "Arbiter") -> None:
def on_exit(_: t.Any) -> None: def on_exit(_: t.Any) -> None:
"""Gunicorn shutdown tasks.""" """Gunicorn shutdown tasks."""
log.critical("Stopping hyperglass {}", __version__)
state = use_state() state = use_state()
if not Settings.dev_mode: state.clear()
state.clear()
log.info("Cleared hyperglass state")
unregister_all_plugins() unregister_all_plugins()
log.critical("Stopping hyperglass {}", __version__)
class HyperglassWSGI(BaseApplication): class HyperglassWSGI(BaseApplication):
"""Custom gunicorn app.""" """Custom gunicorn app."""
@ -185,6 +186,9 @@ def run(_workers: int = None):
try: try:
log.debug("System settings: {!r}", Settings) log.debug("System settings: {!r}", Settings)
state = use_state()
state.clear()
init_user_config() init_user_config()
workers = 1 if Settings.debug else cpu_count(2) workers = 1 if Settings.debug else cpu_count(2)