2022-12-03 17:23:19 +01:00
|
|
|
#!/command/with-contenv bash
|
2022-11-22 02:31:39 +01:00
|
|
|
# shellcheck shell=bash
|
2022-12-07 14:47:40 +01:00
|
|
|
# Start the NGINX service
|
2022-11-22 02:31:39 +01:00
|
|
|
|
2023-01-19 00:23:40 +01:00
|
|
|
set -o errexit -o nounset -o pipefail
|
|
|
|
|
2023-02-19 20:11:12 +01:00
|
|
|
# Logs should be sent to stdout so that s6 can collect them
|
|
|
|
|
|
|
|
echo "[INFO] Starting NGINX..."
|
2023-01-19 00:23:40 +01:00
|
|
|
|
2024-05-30 19:34:01 +02:00
|
|
|
function set_worker_processes() {
|
|
|
|
# Capture number of assigned CPUs to calculate worker processes
|
|
|
|
local proc_count
|
|
|
|
|
|
|
|
if proc_count=$(nproc --all) && [[ $proc_count -gt 4 ]]; then
|
|
|
|
proc_count=4;
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i "s/worker_processes auto;/worker_processes ${proc_count};/" /usr/local/nginx/conf/nginx.conf
|
|
|
|
}
|
|
|
|
|
|
|
|
set_worker_processes
|
|
|
|
|
2022-12-07 14:47:40 +01:00
|
|
|
# Replace the bash process with the NGINX process, redirecting stderr to stdout
|
|
|
|
exec 2>&1
|
2022-11-22 02:31:39 +01:00
|
|
|
exec nginx
|