gracefully handle missing appconfig by creating default settings in elasticsearch (#983)

Co-authored-by: skillet <skillet@localhost>
This commit is contained in:
skilletskills 2025-06-04 01:29:19 +09:00 committed by GitHub
parent 8a227fc9b8
commit b239f4bd84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -201,7 +201,15 @@ class ElasitIndexWrap:
if self.backup_run:
return
try:
config = AppConfig().config
except ValueError:
# create defaults in ES if config not found
print("AppConfig not found, creating defaults...")
handler = AppConfig.__new__(AppConfig)
handler.sync_defaults()
config = AppConfig.CONFIG_DEFAULTS
if config["application"]["enable_snapshot"]:
# take snapshot if enabled
ElasticSnapshot().take_snapshot_now(wait=True)