aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-07-18 11:32:44 +0300
committerFrederick Muriuki Muriithi2022-07-19 05:08:17 +0300
commit044184ef28a091519b7632d582387c26bf1543ea (patch)
tree5c3a08605148d5a718cbb0ecd8fc6d9965242250 /scripts
parent52024b1f6cde74b51181ce4108cf01611a7ea636 (diff)
downloadgn-uploader-044184ef28a091519b7632d582387c26bf1543ea.tar.gz
Check connections before launching
* qc_app/__init__.py (refactor): Check connection before launching the application * qc_app/check_connections.py (new file): Add code to check connections * qc_app/db_utils.py (refactor): enable passing the database uri as an argument to the connection creation function. * scripts/worker.py (refactor): Use new code to check for redis connection.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/worker.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/scripts/worker.py b/scripts/worker.py
index 4077ad1..fee4ec8 100644
--- a/scripts/worker.py
+++ b/scripts/worker.py
@@ -10,6 +10,7 @@ from tempfile import TemporaryFile
from redis import Redis
from qc_app import jobs
+from qc_app.check_connections import check_redis
def parse_args():
"Parse the command-line arguments"
@@ -21,11 +22,7 @@ def parse_args():
parser.add_argument("job_id", help="The id of the job being processed")
args = parser.parse_args()
- try:
- conn = Redis.from_url(args.redisurl) # pylint: disable=[unused-variable]
- except ConnectionError as conn_err: # pylint: disable=[unused-variable]
- print(traceback.format_exc(), file=sys.stderr)
- sys.exit(1)
+ check_redis(args.redisurl)
return args