From bcc25ef42fb86422c38598c49d23a3e0054533fb Mon Sep 17 00:00:00 2001 From: devlikepro Date: Fri, 25 Jul 2025 11:32:13 +0700 Subject: [PATCH] [core] Adjust UV_THREADPOOL_SIZE logic --- entrypoint.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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}"