From 341c64d6dcb662a27bf6cda5ed8640c5cab53d2a Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Thu, 25 Apr 2024 16:23:07 -0400 Subject: [PATCH] service health check added Signed-off-by: 2byrds <2byrds@gmail.com> --- docker-compose.yml | 53 +++++++++++++++++++++++++++------- src/verifier/core/verifying.py | 9 ++++++ 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e26e3dc..2866cbd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ version: '3.8' # reg: services: - witnesses: + witness-demo: # container_name: witnesshost # hostname: witnesshost image: 2byrds/keripy:latest @@ -17,17 +17,33 @@ services: - 5643:5643 # witness - 5644:5644 # witness entrypoint: kli witness demo + healthcheck: + test: ['CMD', 'curl', '-f', 'http://localhost:5642/oobi'] + interval: 2s + timeout: 3s + retries: 5 + start_period: 2s - vlei: + vlei-server: image: 2byrds/vlei:latest - container_name: vlei - hostname: vlei + container_name: vlei-server + hostname: vlei-server ports: - 7723:7723 environment: - PYTHONUNBUFFERED=1 - PYTHONIOENCODING=UTF-8 entrypoint: [ "vLEI-server", "-s", "./schema/acdc", "-c" , "./samples/acdc/", "-o", "./samples/oobis/" ] + healthcheck: + test: + - CMD + - curl + - -f + - http://localhost:7723/oobi/EBfdlu8R27Fbx-ehrqwImnK-8Cm79sqbAQ4MmvEAYqao + interval: 2s + timeout: 3s + retries: 5 + start_period: 2s vlei-verifier: build: @@ -37,11 +53,28 @@ services: container_name: vlei-verifier hostname: vlei-verifier depends_on: - - vlei - - witnesses + - vlei-server + - witness-demo ports: - 7676:7676 - # networks: - # - reg - # volumes: - # - './data/keri:/usr/local/var/keri' \ No newline at end of file + healthcheck: + test: + - CMD + - curl + - -f + - http://localhost:7676/health + interval: 2s + timeout: 3s + retries: 5 + start_period: 2s + + deps: + image: alpine + command: ['echo', 'Dependencies running'] + depends_on: + vlei-server: + condition: service_healthy + vlei-verifier: + condition: service_healthy + witness-demo: + condition: service_healthy \ No newline at end of file diff --git a/src/verifier/core/verifying.py b/src/verifier/core/verifying.py index 9c61734..3bce7c7 100644 --- a/src/verifier/core/verifying.py +++ b/src/verifier/core/verifying.py @@ -34,6 +34,8 @@ def loadEnds(app, hby, vdb, tvy, vry): """ + healthEnd = HealthEndpoint() + app.add_route("/health", healthEnd) presentEnd = PresentationResourceEndpoint(hby, vdb, tvy, vry) app.add_route("/presentations/{said}", presentEnd) presentResEnd = AuthorizationResourceEnd(hby, vdb) @@ -260,3 +262,10 @@ def on_post(self, req, rep, aid): raise falcon.HTTPUnauthorized(description=f"{aid} provided invalid signature on request data") rep.status = falcon.HTTP_ACCEPTED + +class HealthEndpoint: + def __init__(self): + pass + def on_get(self, req, rep): + rep.status = falcon.HTTP_OK + rep.data = json.dumps(dict(health="vLEI verification service is healthy")).encode("utf-8") \ No newline at end of file