Skip to content

Commit f00caa7

Browse files
committed
Switch startup script bash to exec for clean sigterm handling & better process management.
1 parent f7a69d8 commit f00caa7

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

start_service_debug.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ else
5252
exit 1
5353
fi
5454

55-
$python_version -m gunicorn wsgi:app --worker-class "$OCR_SERVICE_WORKER_CLASS" \
56-
--bind "$OCR_SERVICE_HOST:$OCR_SERVICE_PORT" \
57-
--threads "1" \
58-
--workers "$OCR_WEB_SERVICE_WORKERS" \
59-
--access-logfile "$OCR_SERVICE_GUNICORN_LOG_FILE_PATH" \
60-
--reload --log-level "debug" \
61-
--max-requests "$OCR_SERVICE_GUNICORN_MAX_REQUESTS" \
62-
--max-requests-jitter "$OCR_SERVICE_GUNICORN_MAX_REQUESTS_JITTER" \
63-
--timeout "$OCR_SERVICE_GUNICORN_TIMEOUT" \
64-
--graceful-timeout "$OCR_SERVICE_GUNICORN_GRACEFUL_TIMEOUT"
55+
gunicorn_cmd=("$python_version" "-m" "gunicorn")
56+
57+
exec "${gunicorn_cmd[@]}" wsgi:app --worker-class "$OCR_SERVICE_WORKER_CLASS" \
58+
--bind "$OCR_SERVICE_HOST:$OCR_SERVICE_PORT" \
59+
--threads "1" \
60+
--workers "$OCR_WEB_SERVICE_WORKERS" \
61+
--access-logfile "$OCR_SERVICE_GUNICORN_LOG_FILE_PATH" \
62+
--reload --log-level "debug" \
63+
--max-requests "$OCR_SERVICE_GUNICORN_MAX_REQUESTS" \
64+
--max-requests-jitter "$OCR_SERVICE_GUNICORN_MAX_REQUESTS_JITTER" \
65+
--timeout "$OCR_SERVICE_GUNICORN_TIMEOUT" \
66+
--graceful-timeout "$OCR_SERVICE_GUNICORN_GRACEFUL_TIMEOUT"

start_service_production.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if [[ -x "$VIRTUAL_ENV/bin/gunicorn" ]]; then
3636
export VIRTUAL_ENV
3737
export PATH="$VIRTUAL_ENV/bin:$PATH"
3838
python_cmd="$VIRTUAL_ENV/bin/python"
39-
gunicorn_cmd="$VIRTUAL_ENV/bin/gunicorn"
39+
gunicorn_cmd=("$VIRTUAL_ENV/bin/gunicorn")
4040
else
4141
# Fallback to system python if venv missing
4242
python_cmd=python3
@@ -47,16 +47,16 @@ else
4747
elif command -v python3.13 &>/dev/null; then
4848
python_cmd=python3.13
4949
fi
50-
gunicorn_cmd="$python_cmd -m gunicorn"
50+
gunicorn_cmd=("$python_cmd" "-m" "gunicorn")
5151
fi
5252

53-
$gunicorn_cmd wsgi:app --worker-class "$OCR_SERVICE_WORKER_CLASS" \
54-
--bind "$OCR_SERVICE_HOST:$OCR_SERVICE_PORT" \
55-
--threads "1" \
56-
--workers "$OCR_WEB_SERVICE_WORKERS" \
57-
--access-logfile "$OCR_SERVICE_GUNICORN_LOG_FILE_PATH" \
58-
--log-level "$OCR_SERVICE_GUNICORN_LOG_LEVEL" \
59-
--max-requests "$OCR_SERVICE_GUNICORN_MAX_REQUESTS" \
60-
--max-requests-jitter "$OCR_SERVICE_GUNICORN_MAX_REQUESTS_JITTER" \
61-
--timeout "$OCR_SERVICE_GUNICORN_TIMEOUT" \
62-
--graceful-timeout "$OCR_SERVICE_GUNICORN_GRACEFUL_TIMEOUT"
53+
exec "${gunicorn_cmd[@]}" wsgi:app --worker-class "$OCR_SERVICE_WORKER_CLASS" \
54+
--bind "$OCR_SERVICE_HOST:$OCR_SERVICE_PORT" \
55+
--threads "1" \
56+
--workers "$OCR_WEB_SERVICE_WORKERS" \
57+
--access-logfile "$OCR_SERVICE_GUNICORN_LOG_FILE_PATH" \
58+
--log-level "$OCR_SERVICE_GUNICORN_LOG_LEVEL" \
59+
--max-requests "$OCR_SERVICE_GUNICORN_MAX_REQUESTS" \
60+
--max-requests-jitter "$OCR_SERVICE_GUNICORN_MAX_REQUESTS_JITTER" \
61+
--timeout "$OCR_SERVICE_GUNICORN_TIMEOUT" \
62+
--graceful-timeout "$OCR_SERVICE_GUNICORN_GRACEFUL_TIMEOUT"

0 commit comments

Comments
 (0)