From 6f94dac2e8d49e0a2a0bd5d11de81b6ef78ebf42 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 11 Jul 2023 17:10:43 -0600 Subject: [PATCH] Setting Kiwix restart flag when service can't be restarted. --- modules/zim/downloader.py | 2 -- modules/zim/lib.py | 16 ++++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/modules/zim/downloader.py b/modules/zim/downloader.py index 504fa632..d75b9a45 100644 --- a/modules/zim/downloader.py +++ b/modules/zim/downloader.py @@ -87,8 +87,6 @@ class KiwixZimDownloader(Downloader): # Notify the maintainer if outdated Zim files are lying around. lib.flag_outdated_zim_files() - # Notify the maintainer to restart Kiwix container. - lib.flag_kiwix_restart() output_size = output_path.stat().st_size if download_info.size and output_size != download_info.size: diff --git a/modules/zim/lib.py b/modules/zim/lib.py index 03cad581..592d7b1e 100644 --- a/modules/zim/lib.py +++ b/modules/zim/lib.py @@ -461,7 +461,7 @@ async def remove_outdated_zim_files(path: pathlib.Path = None): else: background_task(refresh_files(outdated)) - flag_kiwix_restart() + await restart_kiwix() @register_refresh_cleanup @@ -476,17 +476,13 @@ def flag_outdated_zim_files(): flags.outdated_zims.clear() -def flag_kiwix_restart(): - """Set `kiwix_restart` Flag only if running in Docker.""" - if DOCKERIZED: - flags.kiwix_restart.set() - else: - logger.debug(f'Not setting kiwix_restart flag because this is not Dockerized') - - async def restart_kiwix(): if DOCKERIZED: - logger.warning('Unable to restart Kiwix serve because it is in a docker container') + logger.warning('Setting Kiwix restart because this is in a docker container') + flags.kiwix_restart.set() + return + if PYTEST: + logger.warning('Unable to restart Kiwix serve because we are testing') return logger.info('Restarting Kiwix serve')