diff --git a/entrypoint.sh b/entrypoint.sh index c1bb80e2..98b7e7ea 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,9 +4,19 @@ # # Calculate UV_THREADPOOL_SIZE based on number of CPUs # -cpus=$(node -e "const os = require('os'); console.log(os.cpus().length);") +# Try to get CPU count using Node.js, fallback to 1 if it fails +cpus=$(node -e "const os = require('os'); console.log(os.cpus().length);" 2>/dev/null) || cpus=1 +# Make sure cpus is a number, default to 1 if not +case $cpus in + ''|*[!0-9]*) cpus=1 ;; +esac uv_threadpool_size=$(($cpus * 1)) +# Check if uv_threadpool_size is less than 4 (default), set it to 4 if it is +if [ "$uv_threadpool_size" -lt 4 ]; then + uv_threadpool_size=4 +fi + # Set UV_THREADPOOL_SIZE as an environment variable export UV_THREADPOOL_SIZE="${UV_THREADPOOL_SIZE:-$uv_threadpool_size}"