From d8e90aa37d164d2311d20a8e17a751bd909ff063 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 30 Jun 2014 18:05:04 +0530 Subject: [PATCH] Better way to perform search/replace inside php upstream only --- src/modules/debug/ee_mod_debug_php.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/debug/ee_mod_debug_php.sh b/src/modules/debug/ee_mod_debug_php.sh index 1b9032b0..55401c21 100644 --- a/src/modules/debug/ee_mod_debug_php.sh +++ b/src/modules/debug/ee_mod_debug_php.sh @@ -3,10 +3,10 @@ function ee_mod_debug_php() { if [ "$1" = "start" ]; then - grep -B2 9001 /etc/nginx/conf.d/upstream.conf | grep php &>> $EE_COMMAND_LOG + sed -n "/upstream php {/,/}/p" /etc/nginx/conf.d/upstream.conf | grep 9001 &>> $EE_COMMAND_LOG if [ $? -ne 0 ]; then ee_lib_echo "Setup PHP5-FPM slow log, please wait..." - sed -i "5 s/9000/9001/" /etc/nginx/conf.d/upstream.conf \ + sed -i "/upstream php {/,/}/s/9000/9001/" /etc/nginx/conf.d/upstream.conf \ || ee_lib_error "Unable to setup PHP5-FPM slow log, exit status = " $? # NGINX reload trigger @@ -16,10 +16,10 @@ function ee_mod_debug_php() ee_lib_echo "PHP5-FPM slow log already enabled" fi elif [ "$1" = "stop" ]; then - grep -B2 9001 /etc/nginx/conf.d/upstream.conf | grep php &>> $EE_COMMAND_LOG + sed -n "/upstream php {/,/}/p" /etc/nginx/conf.d/upstream.conf | grep 9001 &>> $EE_COMMAND_LOG if [ $? -eq 0 ]; then ee_lib_echo "Disable PHP5-FPM slow log, please wait..." - sed -i "5 s/9001/9000/" /etc/nginx/conf.d/upstream.conf \ + sed -i "/upstream php {/,/}/s/9001/9000/" /etc/nginx/conf.d/upstream.conf \ || ee_lib_error "Unable to disable PHP5-FPM slow log, exit status = " $? # NGINX reload trigger