Restrict nginx to 4 processes if more are available

This commit is contained in:
Nicolas Mowen 2024-05-30 09:25:27 -06:00
parent 3e6b8c23bc
commit dfd0649335

View File

@ -8,6 +8,19 @@ set -o errexit -o nounset -o pipefail
echo "[INFO] Starting NGINX..."
function set_worker_processes() {
# Capture number of assigned CPUs to calculate worker processes
local proc_count = $(nproc --all)
if (proc_count > 4) {
proc_count = 4;
}
sed -i "" "s/worker_processes auto;/worker_processes ${proc_count};/" /usr/local/nginx/conf/nginx.conf
}
set_worker_processes
# Replace the bash process with the NGINX process, redirecting stderr to stdout
exec 2>&1
exec nginx