mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-25 09:21:04 +00:00
Merge pull request #394 from jonathan-chin/main
added script to allow healthcheck call in docker-compose
This commit is contained in:
commit
ec87536412
3 changed files with 22 additions and 0 deletions
|
@ -170,6 +170,15 @@ Run this version with:
|
||||||
docker-compose -f docker-compose.cuda.yml up -d --build
|
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
|
## Arguments
|
||||||
|
|
||||||
| Argument | Description | Default | Env. name |
|
| Argument | Description | Default | Env. name |
|
||||||
|
|
|
@ -9,6 +9,8 @@ services:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD-SHELL', './venv/bin/python healthcheck.py']
|
||||||
## Uncomment above command and define your args if necessary
|
## Uncomment above command and define your args if necessary
|
||||||
# command: --ssl --ga-id MY-GA-ID --req-limit 100 --char-limit 500
|
# 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
|
## Uncomment this section and the `volumes` section if you want to backup your API keys
|
||||||
|
|
11
healthcheck.py
Normal file
11
healthcheck.py
Normal 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
|
Loading…
Reference in a new issue