File: //sbin/init-scripts/prestart/nginx-worker-processes.sh
#!/bin/bash
if [[ "$X_APPLICATION_HTTP_SERVER" != "nginx" ]]; then
exit 0
fi
HOME_DIR=/var/www/html/
FILES=($(grep -r "^\s*worker_processes.*;$" "$HOME_DIR/nginx-conf/" | sed 's/;//' | awk '$NF > 10' | cut -d ':' -f 1))
for i in "${FILES[@]}"
do
sed -i "s/^\s*worker_processes.*;$/worker_processes 10;/g" $i
done
FILES_ZERO_WP=($(grep -r "^\s*worker_processes.*;$" "$HOME_DIR/nginx-conf/" | sed 's/;//' | awk '$NF < 1' | cut -d ':' -f 1))
for i in "${FILES_ZERO_WP[@]}"
do
sed -i "s/^\s*worker_processes.*;$/worker_processes 1;/g" $i
done
exit 0