refac: production mode startup logic
This commit is contained in:
parent
b8b1c30313
commit
2b17aa5b8f
3 changed files with 16 additions and 4 deletions
3
api/.vscode/launch.json
vendored
3
api/.vscode/launch.json
vendored
|
@ -16,6 +16,9 @@
|
||||||
"PYDEVD_DISABLE_FILE_VALIDATION": "1",
|
"PYDEVD_DISABLE_FILE_VALIDATION": "1",
|
||||||
"LOG_LEVEL": "DEBUG",
|
"LOG_LEVEL": "DEBUG",
|
||||||
"WEBDAV__CACHE_TTL": "30",
|
"WEBDAV__CACHE_TTL": "30",
|
||||||
|
// "PRODUCTION_MODE": "true",
|
||||||
|
// "WEBDAV__RETRIES": "5",
|
||||||
|
// "WEBDAV__RETRY_DELAY": "1",
|
||||||
},
|
},
|
||||||
"justMyCode": true
|
"justMyCode": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,15 +53,23 @@ if SETTINGS.production_mode:
|
||||||
name="frontend",
|
name="frontend",
|
||||||
)
|
)
|
||||||
|
|
||||||
for _ in range(SETTINGS.webdav.retries):
|
def check_webdav(retry: int) -> bool | None:
|
||||||
if WebDAV._webdav_client.check(""):
|
if WebDAV._webdav_client.check(""):
|
||||||
break
|
return True
|
||||||
|
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
"Waiting for WebDAV connection to %s ...",
|
"WebDAV connection to %s failed (try %d of %d)",
|
||||||
repr(SETTINGS.webdav.url),
|
repr(SETTINGS.webdav.url),
|
||||||
|
retry + 1,
|
||||||
|
SETTINGS.webdav.retries,
|
||||||
)
|
)
|
||||||
time.sleep(30)
|
|
||||||
|
if retry < SETTINGS.webdav.retries:
|
||||||
|
_logger.debug("Retrying in %d seconds ...", SETTINGS.webdav.retry_delay)
|
||||||
|
time.sleep(SETTINGS.webdav.retry_delay)
|
||||||
|
|
||||||
|
if not any(check_webdav(n) for n in range(SETTINGS.webdav.retries)):
|
||||||
|
raise ConnectionError("WebDAV connection failed")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
assert WebDAV._webdav_client.check("")
|
assert WebDAV._webdav_client.check("")
|
||||||
|
|
|
@ -54,6 +54,7 @@ class WebDAVSettings(DAVSettings):
|
||||||
|
|
||||||
disable_check: bool = False
|
disable_check: bool = False
|
||||||
retries: int = 20
|
retries: int = 20
|
||||||
|
retry_delay: int = 30
|
||||||
prefix: str = "/ovdashboard"
|
prefix: str = "/ovdashboard"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in a new issue