From d4ac09173553aa83e4bdb892b3afaf8cf067d340 Mon Sep 17 00:00:00 2001 From: mags0ft Date: Sat, 27 Dec 2025 18:00:58 +0100 Subject: [PATCH] add timeout for llama-server startup to prevent indefinite waiting --- src/start.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/start.sh b/src/start.sh index 47f59d4..63f0afe 100644 --- a/src/start.sh +++ b/src/start.sh @@ -65,6 +65,8 @@ LD_LIBRARY_PATH=/app /app/llama-server $CACHED_LLAMA_ARGS $LLAMA_SERVER_CMD_ARGS LLAMA_SERVER_PID=$! # store the process ID (PID) of the background command +tries_so_far=0 + check_server_is_running() { echo "start.sh: Checking if llama-server is done initializing..." @@ -74,6 +76,13 @@ check_server_is_running() { return 1 # failure fi + tries_so_far=$((tries_so_far + 1)) + + if [ $tries_so_far -ge 120 ]; then + echo "start.sh: Error: llama-server did not start within 60 seconds." + exit 1 + fi + # check if the process is still running if ! kill -0 $LLAMA_SERVER_PID 2>/dev/null; then echo "start.sh: Error: llama-server process has exited unexpectedly."