Merge pull request #394 from jonathan-chin/main

added script to allow healthcheck call in docker-compose
This commit is contained in:
Piero Toffanin 2023-01-16 12:15:50 -05:00 committed by GitHub
commit ec87536412
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -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 |

View file

@ -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

11
healthcheck.py Normal file
View file

@ -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