From b9a6e093abd0efe35b069b16d093948c1aa9f2da Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Fri, 26 Mar 2021 16:49:18 +0100 Subject: [PATCH] better handle connection errors to db --- start.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/start.py b/start.py index 8d60a14403..c231786797 100644 --- a/start.py +++ b/start.py @@ -100,6 +100,8 @@ import subprocess import site from pathlib import Path +from pymongo.errors import ServerSelectionTimeoutError + # add dependencies folder to sys.pat for frozen code if getattr(sys, 'frozen', False): frozen_libs = os.path.normpath( @@ -569,7 +571,13 @@ def boot(): # Get Pype path from database and set it to environment so Pype can # find its versions there and bootstrap them. - pype_path = get_pype_path_from_db(pype_mongo) + try: + pype_path = get_pype_path_from_db(pype_mongo) + except ServerSelectionTimeoutError as e: + print("!!! Can't connect to mongodb database server.") + print("!!! {}".format(e)) + sys.exit(1) + if not os.getenv("PYPE_PATH") and pype_path: os.environ["PYPE_PATH"] = pype_path