Skip to content

Commit 664541c

Browse files
fix: added db retry mechanism to mcpgateway/db.py (#226)
* fix: added db retry mechanism to mcpgateway/db.py Signed-off-by: reevebarreto <[email protected]> * cleaned code to a one liner Signed-off-by: reevebarreto <[email protected]> * Flake8 fix Signed-off-by: Mihai Criveti <[email protected]> --------- Signed-off-by: reevebarreto <[email protected]> Signed-off-by: Mihai Criveti <[email protected]> Co-authored-by: Mihai Criveti <[email protected]>
1 parent 82bc310 commit 664541c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mcpgateway/db.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from mcpgateway.config import settings
2626
from mcpgateway.types import ResourceContent
2727
from mcpgateway.utils.create_slug import slugify
28+
from mcpgateway.utils.db_isready import wait_for_db_ready
2829

2930
# Third-Party
3031
import jsonschema
@@ -1220,4 +1221,7 @@ def init_db():
12201221

12211222

12221223
if __name__ == "__main__":
1224+
# Wait for database to be ready before initializing
1225+
wait_for_db_ready(max_tries=int(settings.db_max_retries), interval=int(settings.db_retry_interval_ms) / 1000, sync=True) # Converting ms to s
1226+
12231227
init_db()

0 commit comments

Comments
 (0)