From 4855952a87a401a39d5de61096aa9f3a6b7de618 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 4 Jun 2014 18:46:41 +0530 Subject: [PATCH] Fix nginx server_names_hash_bucket_size --- src/lib/ee_lib_service.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/lib/ee_lib_service.sh b/src/lib/ee_lib_service.sh index 6167b3b1..b071a0b2 100644 --- a/src/lib/ee_lib_service.sh +++ b/src/lib/ee_lib_service.sh @@ -10,13 +10,34 @@ function ee_lib_service() if [ $ee_service_name != ${@: -1} ]; then # Check nginx and php5-fpm test before start/stop/restart/reload - if [ $ee_service_name = "nginx" ] || [ $ee_service_name = "php5-fpm" ]; then - $ee_service_name -t &> EE_COMMAND_LOG \ + if [ $ee_service_name = "nginx" ]; then + + # Adjust nginx server_names_hash_bucket_size + $ee_service_name -t 2>&1 | grep server_names_hash_bucket_size &>> EE_COMMAND_LOG + if [ $? -eq 0 ];then + EE_NGINX_CALCULATION=$(echo "l($(ls /etc/nginx/sites-enabled/ | wc -c))/l(2)+2" | bc -l) + EE_NGINX_SET_BUCKET=$(echo "2^$EE_NGINX_CALCULATION" | bc -l 2> /dev/null) + sed -i "s/.*server_names_hash_bucket_size.*/\tserver_names_hash_bucket_size $EE_NGINX_SET_BUCKET;/" /etc/nginx/nginx.conf + fi + + # Test and start/stop/restart/reload nginx service + $ee_service_name -t &>> EE_COMMAND_LOG \ && service $ee_service_name ${@: -1} \ || ee_lib_error "Unable to execute service $ee_service_name ${@: -1}, exit status = " $? + + elif [ $ee_service_name = "php5-fpm" ]; then + + # Test and start/stop/restart/reload php5-fpm service + $ee_service_name -t &>> EE_COMMAND_LOG \ + && service $ee_service_name ${@: -1} \ + || ee_lib_error "Unable to execute service $ee_service_name ${@: -1}, exit status = " $? + else + + # start/stop/restart/reload services service $ee_service_name ${@: -1} \ || ee_lib_error "Unable to execute service $ee_service_name ${@: -1}, exit status = " $? + fi fi