From 446dac4a002c356cb18adb94eddbeb3a39139a5d Mon Sep 17 00:00:00 2001 From: I-am-PUID-0 <36779668+I-am-PUID-0@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:55:15 -0400 Subject: [PATCH] Version [3.3.0] --- CHANGELOG.md | 47 +++++++++---- README.md | 2 + base/__init__.py | 3 +- healthcheck.py | 12 ++++ main.py | 2 +- riven_/settings.py | 8 ++- riven_/setup.py | 159 ++++++++++++++++++++++--------------------- riven_/update.py | 62 ++++++++++++++--- utils/auto_update.py | 32 +++++++-- zurg/update.py | 2 + 10 files changed, 215 insertions(+), 114 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33a9647..9f6fe6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 -## Version [3.2.0] - 2024-30-07 🚀 +## Version [3.3.0] - 2024-08-01 🚀 + +### Fixed 🛠️ + +- [Issue #23](https://github.com/I-am-PUID-0/DMB/issues/23) Processes not properly killed during automatic updates 🐛 +- [Issue #24](https://github.com/I-am-PUID-0/DMB/issues/24) Riven automatic update extracts to wrong directory 🐛 +- [Issue #25](https://github.com/I-am-PUID-0/DMB/issues/25) Automatic update initiates update check multiple times for each instance 🐛 +- [Issue #26](https://github.com/I-am-PUID-0/DMB/issues/26) Riven Frontend breaking change requires DIALECT=sqlite env variable 🐛 + +### Added ✨ + +- Automatic Update: Enabled automatic updates for Riven branches - expands automatic updates to include branches 🔄 +- RIVEN_FRONTEND_DIALECT: Environment variable to set the Riven frontend database dialect; Default is sqlite - not required to be set in default configuration 🗃️ +- Riven Frontend: Set npm max_old_space_size to 2048MB for Riven frontend build process - limits resource usage 📦 +- Riven Frontend: Set vite minification to false for Riven frontend build process - speeds up build process and reduces resource usage 📦 + +### Changed 🔄 + +- healthcheck: Waits for Riven frontend setup to complete 🩺 + + +## Version [3.2.0] - 2024-07-30 🚀 ### Changed 🔄 @@ -24,14 +45,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Logging: Fixed logging for Zurg to ensure log levels are properly set 📝 -## Version [3.1.0] - 2024-26-07 🚀 +## Version [3.1.0] - 2024-07-26 🚀 ### Added ✨ - Shutdown: Added a shutdown function to gracefully stop the DMB container; e.g., unmount the rclone mounts 🛑 -## Version [3.0.0] - 2024-26-07 🚀 +## Version [3.0.0] - 2024-07-26 🚀 ### Breaking Changes ⚠️ @@ -58,7 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 -## Version [2.0.0] - 2024-25-07 +## Version [2.0.0] - 2024-07-25 ### Breaking Changes @@ -92,14 +113,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 -## Version [1.2.0] - 2024-19-07 +## Version [1.2.0] - 2024-07-19 ### Added - [Issue #18](https://github.com/I-am-PUID-0/DMB/issues/18): Added DMB_LOG_SIZE environment variable to set the maximum size of the log file; Default is 10MB -## Version [1.1.0] - 2024-17-07 +## Version [1.1.0] - 2024-07-17 ### Changed @@ -107,21 +128,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - DMB: Refactored to use common functions under utils -## Version [1.0.3] - 2024-16-07 +## Version [1.0.3] - 2024-07-16 ### Fixed - Rclone: Fixed WebDAV URL check for Zurg startup processes when Zurg user and password are set in config.yml -## Version [1.0.2] - 2024-16-07 +## Version [1.0.2] - 2024-07-16 ### Fixed - Zurg: Fixed the removal of Zurg user and password if previously set in config.yml -## Version [1.0.1] - 2024-16-07 +## Version [1.0.1] - 2024-07-16 ### Fixed @@ -129,7 +150,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - DMB: Introduced a Rclone startup check for the Zurg WebDAV URL to ensure the Zurg startup processes have finished before starting Rclone -## Version [1.0.0] - 2024-25-06 +## Version [1.0.0] - 2024-06-25 ### Breaking Changes @@ -153,7 +174,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [Issue #2](https://github.com/I-am-PUID-0/DMB/issues/2): Removed PLEX_REFRESH environment variable -## Version [0.2.0] - 2024-22-06 +## Version [0.2.0] - 2024-06-22 ### Added @@ -165,7 +186,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Zurg: PLEX_MOUNT environment variable -## Version [0.1.0] - 2024-22-06 +## Version [0.1.0] - 2024-06-22 ### Added @@ -177,7 +198,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Healthcheck: Fixed healthcheck process w/ Riven -## Version [0.0.1] - 2024-21-06 +## Version [0.0.1] - 2024-06-21 ### Added diff --git a/README.md b/README.md index 0392dd6..c19b487 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ services: # - RIVEN_LOG_LEVEL=DEBUG # - RIVEN_BACKEND_URL=http://127.0.0.1:8080 # Default is http://127.0.0.1:8080 when not enabled # - RIVEN_DATABASE_HOST=sqlite:////riven/backend/data/media.db # Default is sqlite:////riven/backend/data/media.db when not enabled + # - RIVEN_FRONTEND_DIALECT=sqlite # - PLEX_TOKEN= # - PLEX_ADDRESS= # - SEERR_API_KEY= @@ -185,6 +186,7 @@ of this parameter has the format `=`. |`ORIGIN`| The origin URL for the Riven frontend | http://0.0.0.0:3000 | | :heavy_check_mark: | | |`RIVEN_BACKEND_URL`| The URL for the Riven backend | http://127.0.0.1:8080 | | :heavy_check_mark: | | |`RIVEN_DATABASE_HOST`| The database host for Riven | `sqlite:////riven/backend/data/media.db` | | :heavy_check_mark: | | +|`RIVEN_FRONTEND_DIALECT`| The dialect for the Riven frontend | `sqlite` | | :heavy_check_mark: | | |`AUTO_UPDATE_INTERVAL`| Interval between automatic update checks in hours. Vaules can be any positive [whole](https://www.oxfordlearnersdictionaries.com/us/definition/english/whole-number) or [decimal](https://www.oxfordreference.com/display/10.1093/oi/authority.20110803095705740;jsessionid=3FDC96CC0D79CCE69702661D025B9E9B#:~:text=The%20separator%20used%20between%20the,number%20expressed%20in%20decimal%20representation.) point based number. Ex. a value of .5 would yield thirty minutes, and 1.5 would yield one and a half hours | `24` || :heavy_check_mark:| :heavy_check_mark:| |`DUPLICATE_CLEANUP`| Automated cleanup of duplicate content in Plex. | `false` | |`CLEANUP_INTERVAL`| Interval between duplicate cleanup in hours. Values can be any positive [whole](https://www.oxfordlearnersdictionaries.com/us/definition/english/whole-number) or [decimal](https://www.oxfordreference.com/display/10.1093/oi/authority.20110803095705740;jsessionid=3FDC96CC0D79CCE69702661D025B9E9B#:~:text=The%20separator%20used%20between%20the,number%20expressed%20in%20decimal%20representation.) point based number. Ex. a value of .5 would yield thirty minutes and 1.5 would yield one and a half hours | `24` || :heavy_check_mark: | :heavy_check_mark:| diff --git a/base/__init__.py b/base/__init__.py index ffdb4e2..348c0f9 100644 --- a/base/__init__.py +++ b/base/__init__.py @@ -70,4 +70,5 @@ def load_secret_or_env(secret_name, default=None): RBVERSION = os.getenv('RIVEN_BACKEND_VERSION') RFVERSION = os.getenv('RIVEN_FRONTEND_VERSION') RBUPDATE = os.getenv('RIVEN_BACKEND_UPDATE') -RFUPDATE = os.getenv('RIVEN_FRONTEND_UPDATE') \ No newline at end of file +RFUPDATE = os.getenv('RIVEN_FRONTEND_UPDATE') +RFDIALECT = os.getenv('RIVEN_FRONTEND_DIALECT') \ No newline at end of file diff --git a/healthcheck.py b/healthcheck.py index d4e3fef..a9fc956 100644 --- a/healthcheck.py +++ b/healthcheck.py @@ -56,10 +56,22 @@ def check_processes(process_info): "regex": re.compile(rf'rclone {mount_type} {re.escape(RCLONEMN_AD)}:'), "error_message": f"The Rclone AD process for {RCLONEMN_AD} is not running.", "should_run": str(ZURG).lower() == 'true' and ADAPIKEY and os.path.exists(f'/healthcheck/{RCLONEMN}') + }, + "vite_build": { + "regex": re.compile(r'node --max-old-space-size=2048 /riven/frontend/node_modules/.bin/vite build'), + "error_message": "", + "should_run": True + }, + "npm_install": { + "regex": re.compile(r'npm install'), + "error_message": "", + "should_run": True } } process_status = check_processes(process_info) + if process_status["vite_build"] or process_status["npm_install"]: + process_info["riven_frontend"]["should_run"] = False for process_name, info in process_info.items(): if info["should_run"] and not process_status[process_name]: diff --git a/main.py b/main.py index 7552172..480b984 100644 --- a/main.py +++ b/main.py @@ -25,7 +25,7 @@ def shutdown(signum, frame): def main(): logger = get_logger() - version = '3.2.0' + version = '3.3.0' ascii_art = f''' diff --git a/riven_/settings.py b/riven_/settings.py index 778dfa2..0fe238f 100644 --- a/riven_/settings.py +++ b/riven_/settings.py @@ -39,12 +39,14 @@ def set_env_variable(key, value, default=None): 'SYMLINK_RCLONE_PATH': f"/data/{RCLONEMN}/__all__", 'SYMLINK_LIBRARY_PATH': "/mnt", 'BACKEND_URL': RIVENBACKENDURL, - 'DATABASE_HOST': RIVENDATABASEHOST + 'DATABASE_HOST': RIVENDATABASEHOST, + 'DIALECT' : RFDIALECT } default_env_vars = { 'DATABASE_HOST': 'sqlite:////riven/backend/data/media.db', - 'BACKEND_URL': 'http://127.0.0.1:8080' + 'BACKEND_URL': 'http://127.0.0.1:8080', + 'DIALECT' : 'sqlite' } for key, value in env_vars.items(): @@ -114,7 +116,7 @@ def update_settings(current_settings, updated_settings, prefix=''): def load_settings(): logger.info("Loading Riven settings") - set_env_variables() + #set_env_variables() #set_debug_level('RIVEN_LOG_LEVEL') # An error occurred in the Riven setup: 'bool' object has no attribute 'items' #set_debug_level('DMB_LOG_LEVEL') # An error occurred in the Riven setup: 'bool' object has no attribute 'items' diff --git a/riven_/setup.py b/riven_/setup.py index e862b10..c8483c2 100644 --- a/riven_/setup.py +++ b/riven_/setup.py @@ -10,84 +10,85 @@ def riven_setup(process_name, branch='main', release_version=None): backend_dir= os.path.join(riven_dir, "backend") frontend_dir = os.path.join(riven_dir, "frontend") exclude_dirs = None - if process_name == 'Riven_backend': - repo_owner='rivenmedia' - repo_name='riven' - - if RBVERSION is not None: - logger.info(f"Using {branch} branch version {RBVERSION} for {process_name}") - release_version = RBVERSION - from .download import download_and_unzip_release - success, error = download_and_unzip_release(repo_owner, repo_name, release_version, backend_dir) - if not success: - logger.error(f"Failed to download the {release_version} release in {branch} branch for {process_name}: {error}") - raise Exception(f"Failed to download the {release_version} release in {branch} branch for {process_name}: {error}") - if success: - logger.info(f"Sucessfully downloaded the {release_version} release in {branch} branch for {process_name}") - - elif RBBRANCH: - logger.info(f"Using {RBBRANCH} branch for {process_name}") - branch = RBBRANCH - from .download import get_branch - success, error = get_branch(repo_owner, repo_name, branch, backend_dir, exclude_dirs) - if not success: - logger.error(f"Failed to download the {branch} branch for {process_name}: {error}") - raise Exception(f"Failed to download the {branch} branch for {process_name}: {error}") - if success: - logger.info(f"Sucessfully downloaded {branch} branch for {process_name}") - - else: - from .download import get_latest_release - release_version, error = get_latest_release(repo_owner, repo_name) - if not release_version: - logger.error(f"Failed to get the latest release for {process_name}: {error}") - raise Exception(f"Failed to get the latest release for {process_name}: {error}") - from .download import download_and_unzip_release - success, error = download_and_unzip_release(repo_owner, repo_name, release_version, backend_dir) - if not success: - logger.error(f"Failed to download the latest release for {process_name}: {error}") - raise Exception(f"Failed to download the latest release for {process_name}: {error}") - if success: - logger.info(f"Sucessfully downloaded the latest release for {process_name}") - - if process_name == 'Riven_frontend': - repo_owner='rivenmedia' - repo_name='riven-frontend' - if RFVERSION is not None: - logger.info(f"Using {branch} branch version {RFVERSION} for {process_name}") - release_version = RFVERSION - from .download import download_and_unzip_release - success, error = download_and_unzip_release(repo_owner, repo_name, release_version, frontend_dir) - if not success: - logger.error(f"Failed to download the {release_version} release in {branch} branch for {process_name}: {error}") - raise Exception(f"Failed to download the {release_version} release in {branch} branch for {process_name}: {error}") - if success: - logger.info(f"Sucessfully downloaded the {release_version} release in {branch} branch for {process_name}") - - elif RFBRANCH: - logger.info(f"Using {RFBRANCH} branch for {process_name}") - branch = RFBRANCH - from .download import get_branch - success, error = get_branch(repo_owner, repo_name, branch, frontend_dir, exclude_dirs) - if not success: - logger.error(f"Failed to download the {branch} branch for {process_name}: {error}") - raise Exception(f"Failed to download the {branch} branch for {process_name}: {error}") - if success: - logger.info(f"Sucessfully downloaded {branch} branch for {process_name}") - - else: - from .download import get_latest_release - release_version, error = get_latest_release(repo_owner, repo_name) - if not release_version: - logger.error(f"Failed to get the latest release for {process_name}: {error}") - raise Exception(f"Failed to get the latest release for {process_name}: {error}") - from .download import download_and_unzip_release - success, error = download_and_unzip_release(repo_owner, repo_name, release_version, frontend_dir) - if not success: - logger.error(f"Failed to download the latest release for {process_name}: {error}") - raise Exception(f"Failed to download the latest release for {process_name}: {error}") - if success: - logger.info(f"Sucessfully downloaded the latest release for {process_name}") - + try: + if process_name == 'Riven_backend': + repo_owner='rivenmedia' + repo_name='riven' + + if RBVERSION is not None: + logger.info(f"Using {branch} branch version {RBVERSION} for {process_name}") + release_version = RBVERSION + from .download import download_and_unzip_release + success, error = download_and_unzip_release(repo_owner, repo_name, release_version, backend_dir) + if not success: + logger.error(f"Failed to download the {release_version} release in {branch} branch for {process_name}: {error}") + return False, error + logger.info(f"Successfully downloaded the {release_version} release in {branch} branch for {process_name}") + + elif RBBRANCH: + logger.info(f"Using {RBBRANCH} branch for {process_name}") + branch = RBBRANCH + from .download import get_branch + success, error = get_branch(repo_owner, repo_name, branch, backend_dir, exclude_dirs) + if not success: + logger.error(f"Failed to download the {branch} branch for {process_name}: {error}") + return False, error + logger.info(f"Successfully downloaded {branch} branch for {process_name}") + + else: + from .download import get_latest_release + release_version, error = get_latest_release(repo_owner, repo_name) + if not release_version: + logger.error(f"Failed to get the latest release for {process_name}: {error}") + return False, error + from .download import download_and_unzip_release + success, error = download_and_unzip_release(repo_owner, repo_name, release_version, backend_dir) + if not success: + logger.error(f"Failed to download the latest release for {process_name}: {error}") + return False, error + logger.info(f"Successfully downloaded the latest release for {process_name}") + + if process_name == 'Riven_frontend': + repo_owner='rivenmedia' + repo_name='riven-frontend' + if RFVERSION is not None: + logger.info(f"Using {branch} branch version {RFVERSION} for {process_name}") + release_version = RFVERSION + from .download import download_and_unzip_release + success, error = download_and_unzip_release(repo_owner, repo_name, release_version, frontend_dir) + if not success: + logger.error(f"Failed to download the {release_version} release in {branch} branch for {process_name}: {error}") + return False, error + logger.info(f"Successfully downloaded the {release_version} release in {branch} branch for {process_name}") + + elif RFBRANCH: + logger.info(f"Using {RFBRANCH} branch for {process_name}") + branch = RFBRANCH + from .download import get_branch + success, error = get_branch(repo_owner, repo_name, branch, frontend_dir, exclude_dirs) + if not success: + logger.error(f"Failed to download the {branch} branch for {process_name}: {error}") + return False, error + logger.info(f"Successfully downloaded {branch} branch for {process_name}") + + else: + from .download import get_latest_release + release_version, error = get_latest_release(repo_owner, repo_name) + if not release_version: + logger.error(f"Failed to get the latest release for {process_name}: {error}") + return False, error + from .download import download_and_unzip_release + success, error = download_and_unzip_release(repo_owner, repo_name, release_version, frontend_dir) + if not success: + logger.error(f"Failed to download the latest release for {process_name}: {error}") + return False, error + logger.info(f"Successfully downloaded the latest release for {process_name}") + + return True, None + except Exception as e: + logger.error(f"Exception during setup of {process_name}: {e}") + return False, str(e) + if __name__ == "__main__": riven_setup() + diff --git a/riven_/update.py b/riven_/update.py index 4c377b5..106f504 100644 --- a/riven_/update.py +++ b/riven_/update.py @@ -1,9 +1,12 @@ from ast import Try +from os import error from base import * from utils.logger import * from utils.processes import ProcessHandler from utils.auto_update import Update from .download import get_latest_release, get_branch, download_and_unzip_release +from .setup import riven_setup +from .settings import set_env_variables class RivenUpdate(Update, ProcessHandler): @@ -30,9 +33,17 @@ def update_check(self, process_name): self.logger.info(f"Currently installed [v{current_version}] for {process_name}") if process_name == 'Riven_frontend': - version_url = "https://raw.githubusercontent.com/rivenmedia/riven-frontend/main/version.txt" + if RFBRANCH: + branch = RFBRANCH.lower() + version_url = f"https://raw.githubusercontent.com/rivenmedia/riven-frontend/{RFBRANCH}/version.txt" + else: + version_url = "https://raw.githubusercontent.com/rivenmedia/riven-frontend/main/version.txt" else: - version_url = "https://raw.githubusercontent.com/rivenmedia/riven/main/pyproject.toml" + if RBBRANCH: + branch = RBBRANCH.lower() + version_url = f"https://raw.githubusercontent.com/rivenmedia/riven/{branch}/pyproject.toml" + else: + version_url = "https://raw.githubusercontent.com/rivenmedia/riven/main/pyproject.toml" response = requests.get(version_url, timeout=5) response.raise_for_status() @@ -42,20 +53,26 @@ def update_check(self, process_name): if current_version != latest_version: self.logger.info(f"New version available [v{latest_version}] for {process_name}. Updating...") - if process_name == 'Riven_frontend': - success, error = download_and_unzip_release("rivenmedia", "riven-frontend", latest_version, f"./riven/{process_name}") - else: - success, error = get_branch("rivenmedia", "riven", "main", f"./riven/{process_name}", exclude_dirs=None) + + self.logger.debug(f"Calling riven_setup for {process_name}") + result = riven_setup(process_name) + self.logger.debug(f"riven_setup result for {process_name}: {result}") + + if result is None: + self.logger.error(f"riven_setup returned None for {process_name}") + return + + success, error = result if not success: self.logger.error(f"Failed to download update for {process_name}: {error}") else: - self.logger.info(f"Automatic update installed for {process_name} [v{latest_version}]") - self.logger.info(f"Restarting {process_name}") + self.logger.info(f"Automatic update installed for {process_name} [v{latest_version}]") if process_name == 'Riven_frontend' and self.frontend_process: self.stop_process(process_name, None) - elif process_name == 'Riven_backend' and self.backend_process: + elif process_name == 'Riven_backend' and self.backend_process: self.stop_process(process_name, None) + self.logger.info(f"Restarting {process_name}") self.start_process(process_name) else: self.logger.info(f"Automatic update not required for {process_name}") @@ -113,6 +130,7 @@ def start_process(self, process_name, config_dir=None): def setup_poetry_environment(self, config_dir): try: + set_env_variables() self.logger.info(f"Setting up Poetry environment in {config_dir}") result = subprocess.run( ["poetry", "install", "--no-root", "--without", "dev"], @@ -145,13 +163,35 @@ def setup_poetry_environment(self, config_dir): def setup_npm_build(self, config_dir): try: self.logger.info("Setting up Riven_frontend") + set_env_variables() + vite_config_path = os.path.join(config_dir, 'vite.config.ts') + with open(vite_config_path, 'r') as file: + lines = file.readlines() + build_section_exists = any('build:' in line for line in lines) + if not build_section_exists: + for i, line in enumerate(lines): + if line.strip().startswith('export default defineConfig({'): + lines.insert(i + 1, ' build: {\n minify: false\n },\n') + break + with open(vite_config_path, 'w') as file: + file.writelines(lines) + + self.logger.info("vite.config.ts modified to disable minification") + result = subprocess.run(["npm", "install"], cwd=config_dir, check=True, capture_output=True, text=True) self.logger.debug(f"npm install output: {result.stdout}") self.logger.debug(f"npm install errors: {result.stderr}") - result = subprocess.run(["npm", "run", "build"], cwd=config_dir, check=True, capture_output=True, text=True) + result = subprocess.run( + ["node", "--max-old-space-size=2048", "./node_modules/.bin/vite", "build"], + cwd=config_dir, + check=True, + capture_output=True, + text=True + ) self.logger.debug(f"npm run build output: {result.stdout}") self.logger.debug(f"npm run build errors: {result.stderr}") - self.logger.info("npm install complete") + + self.logger.info("npm install and build complete") except subprocess.CalledProcessError as e: self.logger.error(f"Error setting up npm environment: {e}") return None \ No newline at end of file diff --git a/utils/auto_update.py b/utils/auto_update.py index 8a02177..d4ec34c 100644 --- a/utils/auto_update.py +++ b/utils/auto_update.py @@ -3,17 +3,30 @@ from utils.processes import ProcessHandler class Update(ProcessHandler): + _scheduler_initialized = False + _jobs = {} + def __init__(self): logger = get_logger() super().__init__(logger) + self.updating = threading.Lock() + if not Update._scheduler_initialized: + self.scheduler = schedule.Scheduler() + Update._scheduler_initialized = True + else: + self.scheduler = schedule.default_scheduler def update_schedule(self, process_name): - #self.update_check(process_name) interval_minutes = int(self.auto_update_interval() * 60) - schedule.every(interval_minutes).minutes.do(self.update_check, process_name) + self.logger.debug(f"Scheduling automatic update check every {interval_minutes} minutes for {process_name}") + + if process_name not in Update._jobs: + self.scheduler.every(interval_minutes).minutes.do(self.scheduled_update_check, process_name) + Update._jobs[process_name] = True + self.logger.debug(f"Scheduled automatic update check for {process_name}") while True: - schedule.run_pending() + self.scheduler.run_pending() time.sleep(1) def auto_update_interval(self): @@ -26,12 +39,19 @@ def auto_update_interval(self): def auto_update(self, process_name, enable_update): if enable_update: self.logger.info(f"Automatic updates set to {format_time(self.auto_update_interval())} for {process_name}") - initial_update = self.update_check(process_name) self.schedule_thread = threading.Thread(target=self.update_schedule, args=(process_name,)) self.schedule_thread.start() - if not initial_update: - self.start_process(process_name) + self.initial_update_check(process_name) else: self.logger.info(f"Automatic update disabled for {process_name}") self.start_process(process_name) + def initial_update_check(self, process_name): + with self.updating: + if not self.update_check(process_name): + self.start_process(process_name) + + def scheduled_update_check(self, process_name): + with self.updating: + self.update_check(process_name) + diff --git a/zurg/update.py b/zurg/update.py index 39d0cbc..08ab83c 100644 --- a/zurg/update.py +++ b/zurg/update.py @@ -43,6 +43,8 @@ def start_process(self, process_name, config_dir=None): super().start_process(process_name, dir_to_check, command, key_type) def update_check(self, process_name): + self.logger.info(f"Checking for available {process_name} updates") + try: if GHTOKEN: repo_owner = 'debridmediamanager'