From 9da5051ae204d587e114cf7ff54422a3eece68e8 Mon Sep 17 00:00:00 2001 From: Jon Chin Date: Sun, 15 Jan 2023 16:20:47 -0500 Subject: [PATCH 1/3] added example of including healthcheck configuration --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 63bd509..a634356 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: restart: unless-stopped ports: - "5000:5000" + healthcheck: + test: ['CMD-SHELL', './venv/bin/python healthcheck.py'] ## Uncomment above command and define your args if necessary # command: --ssl --ga-id MY-GA-ID --req-limit 100 --char-limit 500 ## Uncomment this section and the `volumes` section if you want to backup your API keys From 83282ab47d3ca1e4d7e446d3c21fc7be491f5540 Mon Sep 17 00:00:00 2001 From: Jon Chin Date: Sun, 15 Jan 2023 16:21:13 -0500 Subject: [PATCH 2/3] small script for testing if service is ready for requests --- healthcheck.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 healthcheck.py diff --git a/healthcheck.py b/healthcheck.py new file mode 100644 index 0000000..cd62b4f --- /dev/null +++ b/healthcheck.py @@ -0,0 +1,11 @@ +import requests +response = requests.post( + url='http://0.0.0.0:5000/translate', + headers={'Content-Type': 'application/json'}, + json={ + 'q': 'Hello World!', + 'source': 'en', + 'target': 'en' + } +) +# if server unavailable then requests with raise exception and healthcheck will fail From b93f11b54807e7bb34b87238f6e14e289e0dc053 Mon Sep 17 00:00:00 2001 From: Jon Chin Date: Sun, 15 Jan 2023 16:29:45 -0500 Subject: [PATCH 3/3] added note about healthcheck --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 51f7352..203cfbe 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,15 @@ Run this version with: docker-compose -f docker-compose.cuda.yml up -d --build ``` +### Running Healthchecks + +You can enable healthchecks by including this in your docker-compose.yml file: + +``` +healthcheck: + test: ['CMD-SHELL', './venv/bin/python healthcheck.py'] +``` + ## Arguments | Argument | Description | Default | Env. name |