Skip to content

Commit 8a412fc

Browse files
committed
check for WORKER and REDIS in the index route
1 parent a7ee56b commit 8a412fc

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

server.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,24 @@ def create_application():
4141
@APP.route(f'{ROUTE_PREFIX}/', methods=['GET'], strict_slashes=False)
4242
def get_root():
4343
"""Root Endpoint for 3scale."""
44-
if collector.utils.ping_redis():
45-
return jsonify(
46-
status='OK',
47-
version=API_VERSION,
48-
message='Up and Running'
49-
)
44+
if not collector.WORKER:
45+
return_code = 500
46+
status = 'Error'
47+
message = 'No worker set'
48+
elif not collector.utils.ping_redis():
49+
return_code = 500
50+
status = 'Error'
51+
message = 'Required service not operational'
52+
else:
53+
return_code = 200
54+
status = 'OK'
55+
message = 'Up and Running'
56+
5057
return jsonify(
51-
status='Error',
58+
status=status,
5259
version=API_VERSION,
53-
message="Required service not operational"
54-
), 500
60+
message=message
61+
), return_code
5562

5663

5764
@APP.route(f'{ROUTE_PREFIX}/v{API_VERSION}/version', methods=['GET'])

0 commit comments

Comments
 (0)