From 5978e0a63694c530191d72a7131bdf8a94d08811 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 4 Dec 2025 14:24:29 -0500 Subject: [PATCH 1/4] Fix health check startup --- scripts/entrypoint.sh | 5 +++-- scripts/healthcheck.py | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 97df086..31b616e 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,6 +1,4 @@ #!/bin/bash - -set -eo pipefail __dirname=$(cd "$(dirname "$0")"; pwd -P) cd "${__dirname}/.." @@ -13,6 +11,7 @@ echo "v$(cat VERSION)" echo "" echo Booting... +touch /tmp/booting.flag if [ -f ./venv/bin/libretranslate ]; then LT_POWERCYCLE=1 ./venv/bin/libretranslate "$@" @@ -20,6 +19,8 @@ else echo "WARNING: Cannot powercycle LibreTranslate (if you are in development mode, that's fine..)" fi +rm -f /tmp/booting.flag + 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' diff --git a/scripts/healthcheck.py b/scripts/healthcheck.py index 31bafa8..4c4b35c 100644 --- a/scripts/healthcheck.py +++ b/scripts/healthcheck.py @@ -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( From 74920bbb2e732c2bdaf90ab835f34c06489da2e8 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 4 Dec 2025 14:24:47 -0500 Subject: [PATCH 2/4] Bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 53adb84..a7ee35a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.2 +1.8.3 From db058cfc7f5295fbcf572ebb6b54693d098c87a4 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 4 Dec 2025 14:38:47 -0500 Subject: [PATCH 3/4] Fix entrypoint.sh bind address in IPV4 only cases --- scripts/entrypoint.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 31b616e..f8cb89f 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -13,7 +13,13 @@ echo "" echo Booting... touch /tmp/booting.flag -if [ -f ./venv/bin/libretranslate ]; then +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 + +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..)" @@ -22,5 +28,5 @@ fi rm -f /tmp/booting.flag 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' +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' From 1340c91bbeb670c1c8fa4e79c6a7adc8a59cdb59 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 4 Dec 2025 14:55:32 -0500 Subject: [PATCH 4/4] Allow --host to be overriden in entrypoint.sh --- scripts/entrypoint.sh | 18 ++++++++++++------ scripts/print_args_env.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index f8cb89f..7d4ceaa 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -13,12 +13,6 @@ echo "" echo Booting... touch /tmp/booting.flag -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 - if [[ -f ./venv/bin/libretranslate ]]; then LT_POWERCYCLE=1 ./venv/bin/libretranslate "$@" else @@ -28,5 +22,17 @@ fi 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' diff --git a/scripts/print_args_env.py b/scripts/print_args_env.py index 080fc1a..cfcb789 100644 --- a/scripts/print_args_env.py +++ b/scripts/print_args_env.py @@ -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):