Merge pull request #894 from pierotofy/bootflag

Fix health checks, bind address in IPv4 only setups
This commit is contained in:
Piero Toffanin 2025-12-04 15:05:59 -05:00 committed by GitHub
commit c7a485220c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 7 deletions

View File

@ -1 +1 @@
1.8.2
1.8.3

View File

@ -1,6 +1,4 @@
#!/bin/bash
set -eo pipefail
__dirname=$(cd "$(dirname "$0")"; pwd -P)
cd "${__dirname}/.."
@ -13,13 +11,28 @@ echo "v$(cat VERSION)"
echo ""
echo Booting...
touch /tmp/booting.flag
if [ -f ./venv/bin/libretranslate ]; then
if [[ -f ./venv/bin/libretranslate ]]; then
LT_POWERCYCLE=1 ./venv/bin/libretranslate "$@"
else
echo "WARNING: Cannot powercycle LibreTranslate (if you are in development mode, that's fine..)"
fi
eval $(./venv/bin/python ./scripts/print_args_env.py "$@")
PROMETHEUS_MULTIPROC_DIR="${__dirname}/../db/prometheus" ./venv/bin/gunicorn -c scripts/gunicorn_conf.py --workers $LT_THREADS --max-requests 250 --timeout 2400 --bind [::]:$LT_PORT 'wsgi:app'
rm -f /tmp/booting.flag
eval $(./venv/bin/python ./scripts/print_args_env.py "$@")
if [[ $LT_HOST == "127.0.0.1" ]]; then
# Default
BIND_ADDR="0.0.0.0"
IPV6_STATUS=$(cat /proc/sys/net/ipv6/conf/all/disable_ipv6)
if [[ $IPV6_STATUS -eq 0 ]]; then
BIND_ADDR="[::]"
fi
else
BIND_ADDR="$LT_HOST"
fi
PROMETHEUS_MULTIPROC_DIR="${__dirname}/../db/prometheus" ./venv/bin/gunicorn -c scripts/gunicorn_conf.py --workers $LT_THREADS --max-requests 250 --timeout 2400 --bind $BIND_ADDR:$LT_PORT 'wsgi:app'

View File

@ -1,5 +1,9 @@
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(

View File

@ -11,7 +11,7 @@ for arg in dir(args):
if not arg.startswith('_'):
value = getattr(args, arg)
def_value = parser.get_default(arg)
if not callable(value) and (value != def_value or arg == 'port' or arg == 'threads'):
if not callable(value) and (value != def_value or arg == 'port' or arg == 'threads' or arg == 'host'):
if isinstance(value, str):
value = value.replace('"', '')
elif isinstance(value, list):