LibreTranslate/scripts/healthcheck.py
2025-12-04 14:24:29 -05:00

16 lines
397 B
Python

import requests
import os
import sys
if os.path.isfile('/tmp/booting.flag'):
sys.exit(0)
port = os.environ.get('LT_PORT', '5000')
response = requests.get(
url=f'http://localhost:{port}/health',
headers={'Content-Type': 'application/json'},
json={},
timeout=60
)
response.raise_for_status() # if server unavailable then requests with raise exception and healthcheck will fail