From 814de8776817db6ea02f7b2d45651dde2479e137 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 29 Oct 2022 15:57:59 +0700 Subject: [PATCH] add snapshot check at startup --- tubearchivist/home/apps.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tubearchivist/home/apps.py b/tubearchivist/home/apps.py index 5f97e5a9..0e562c90 100644 --- a/tubearchivist/home/apps.py +++ b/tubearchivist/home/apps.py @@ -6,6 +6,7 @@ import sys from django.apps import AppConfig from home.src.es.connect import ElasticWrap from home.src.es.index_setup import index_check +from home.src.es.snapshot import ElasticSnapshot from home.src.ta.config import AppConfig as ArchivistConfig from home.src.ta.ta_redis import RedisArchivist @@ -30,6 +31,7 @@ class StartupCheck: self.sync_redis_state() self.set_redis_conf() self.make_folders() + self.snapshot_check() self.set_has_run() def get_has_run(self): @@ -81,6 +83,14 @@ class StartupCheck: if response: print("deleted leftover key from redis: " + lock) + def snapshot_check(self): + """setup snapshot config, create if needed""" + active = self.config_handler.config["application"]["enable_snapshot"] + if not active: + return + + ElasticSnapshot().setup() + def is_invalid(self, version): """return true if es version is invalid, false if ok""" major, minor = [int(i) for i in version.split(".")[:2]]