diff options
Diffstat (limited to 'src/wsgi.py')
-rwxr-xr-x | src/wsgi.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/wsgi.py b/src/wsgi.py index b6a1a10..e090876 100755 --- a/src/wsgi.py +++ b/src/wsgi.py @@ -8,11 +8,23 @@ from fastapi_jwt_auth import AuthJWT from fastapi_jwt_auth.exceptions import AuthJWTException from pydantic import BaseModel from index import CouchIindex - +import time from db import DictDB app = FastAPI() -db = DictDB() + +for i in range(10): + try: + db = DictDB() + except Exception: + print( + f'Database not responding, will try again soon. Attempt {i + 1} of 10.') + else: + break + time.sleep(10) +else: + print('Database did not respond after 10 attempts, quitting.') + sys.exit(-1) def get_pubkey(): |