-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create healthchecks api (#133)
create a new api route /health which return in json the status of the different services Fixes: #67 Add a health endpoint
- Loading branch information
1 parent
d1162e0
commit b351338
Showing
5 changed files
with
483 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from healthcheck import HealthCheck | ||
|
||
from app.utils import connection, get_logger | ||
|
||
logger = get_logger(__name__) | ||
|
||
health = HealthCheck() | ||
|
||
|
||
def test_connect_redis(): | ||
logger.debug("health: testing redis connection") | ||
client = connection.get_redis_client(socket_connect_timeout=5) | ||
if client.ping(): | ||
return True, "Redis connection check succedded!" | ||
return False, "Redis connection check failed!" | ||
|
||
|
||
def test_connect_es(): | ||
logger.debug("health: testing es connection") | ||
es = connection.get_es_client(timeout=5) | ||
if es.ping(): | ||
return True, "es0 connection check succedded!" | ||
return False, "es0 connection check failed!" | ||
|
||
|
||
health.add_check(test_connect_redis) | ||
health.add_check(test_connect_es) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.