From 5648e3a6c4363a5d33ebc7d327ecea2cf92ed7af Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 2 Jul 2020 13:40:23 +0530 Subject: [PATCH] feat: ping additional services using doctor handle error docs entry for health check command --- build/common/commands/doctor.py | 11 ++++++++++- docs/site-operations.md | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/build/common/commands/doctor.py b/build/common/commands/doctor.py index 5354e476..1cb9b200 100644 --- a/build/common/commands/doctor.py +++ b/build/common/commands/doctor.py @@ -32,9 +32,18 @@ def main(): print("Redis Queue Connected") check_redis_socketio(retry=1, delay=0, print_attempt=False) print("Redis SocketIO Connected") + if(args.ping_services): for service in args.ping_services: - service_name, service_port = service.split(':') + service_name = None + service_port = None + + try: + service_name, service_port = service.split(':') + except ValueError: + print('Service should be in format host:port, e.g postgres:5432') + exit(1) + check_service( retry=1, delay=0, diff --git a/docs/site-operations.md b/docs/site-operations.md index f6dab293..6211e928 100644 --- a/docs/site-operations.md +++ b/docs/site-operations.md @@ -189,3 +189,15 @@ docker run \ ``` Instead of `alpine` use any image of your choice. + +## Health check + +For socketio and gunicorn service ping the hostname:port and that will be sufficient. For workers and scheduler, there is a command that needs to be executed. + +```shell +docker exec -it _erpnext-worker-d \ + docker-entrypoint.sh doctor -p postgresql-master.pgsql.svc.cluster.local:5432 +``` + +This check ensures that given service should be connected along with services in common_site_config.json. +If connection to service(s) fails, the command fails with exit code 1.