From 2abcb52a535ae93f242e80b61f47cf2c8290dcdf Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 2 Nov 2025 11:13:36 +0700 Subject: [PATCH] set startup timestam single thread in ta_startup --- backend/config/management/commands/ta_startup.py | 12 ++++++++++++ backend/config/settings.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/config/management/commands/ta_startup.py b/backend/config/management/commands/ta_startup.py index 3d0717c7..a0eb6863 100644 --- a/backend/config/management/commands/ta_startup.py +++ b/backend/config/management/commands/ta_startup.py @@ -52,6 +52,7 @@ class Command(BaseCommand): self._create_default_schedules() self._update_schedule_tz() self._init_app_config() + self._set_ta_startup_time() self._mig_fix_download_channel_indexed() self._mig_add_default_playlist_sort() self._mig_set_channel_tabs() @@ -259,6 +260,17 @@ class Command(BaseCommand): self.style.SUCCESS(f" Status code: {status_code}") ) + def _set_ta_startup_time(self) -> None: + """set startup time to trigger frontend refresh, threadsafe""" + self.stdout.write("[11] Set startup timestamp") + message = str(int(datetime.now().timestamp() // 10 * 10)) + RedisArchivist().set_message( + "STARTTIMESTAMP", message=message, save=True + ) + self.stdout.write( + self.style.SUCCESS(f" ✓ set timestamp to {message}.") + ) + def _mig_fix_download_channel_indexed(self) -> None: """migrate from v0.5.2 to 0.5.3, fix missing channel_indexed""" self.stdout.write("[MIGRATION] fix incorrect video channel tags types") diff --git a/backend/config/settings.py b/backend/config/settings.py index b5fb184c..bf0c35f5 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -11,12 +11,12 @@ https://docs.djangoproject.com/en/3.2/ref/settings/ """ import hashlib -from datetime import datetime from os import environ, path from pathlib import Path from common.src.env_settings import EnvironmentSettings from common.src.helper import ta_host_parser +from common.src.ta_redis import RedisArchivist from corsheaders.defaults import default_headers try: @@ -228,7 +228,7 @@ CORS_EXPOSE_HEADERS = ["X-Start-Timestamp"] # TA application settings TA_UPSTREAM = "https://github.com/tubearchivist/tubearchivist" TA_VERSION = "v0.5.8-unstable" -TA_START = str(int(datetime.now().timestamp() // 10 * 10)) # round it +TA_START = RedisArchivist().get_message_str("STARTTIMESTAMP") # API REST_FRAMEWORK = {