Browse Source

debug php slowlog and xdebug profiling

old-stable
Mitesh Shah 11 years ago
parent
commit
fd5e859dea
  1. 32
      src/modules/debug/ee_mod_debug_php.sh
  2. 32
      src/modules/debug/ee_mod_debug_php_start.sh
  3. 32
      src/modules/debug/ee_mod_debug_php_stop.sh

32
src/modules/debug/ee_mod_debug_php.sh

@ -0,0 +1,32 @@
# PHP debug
function ee_mod_debug_php()
{
if [ "$1" = "start" ]; then
grep -B2 9001 /etc/nginx/conf.d/upstream.conf | grep php &>> $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 \
|| ee_lib_error "Unable to setup PHP5-FPM slow log, exit status = " $?
# NGINX reload trigger
EE_TRIGGER_NGINX="true"
else
# Display message
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
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 \
|| ee_lib_error "Unable to disable PHP5-FPM slow log, exit status = " $?
# NGINX reload trigger
EE_TRIGGER_NGINX="true"
else
# Display message
ee_lib_echo "PHP5-FPM slow log already disabled"
fi
fi
}

32
src/modules/debug/ee_mod_debug_php_start.sh

@ -1,32 +0,0 @@
# Enables PHP debug mode
function ee_mod_debug_php_start()
{
# Lets disable PHP restart trigger
EE_DEBUG_PHP=""
if [ -z $EE_DEBUG_SITENAME ]; then
grep -B2 9001 /etc/nginx/conf.d/upstream.conf \
| grep php &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
ee_lib_echo "Enable PHP5-FPM slow log, please wait..."
sed -i "4 s/9000/9001/" /etc/nginx/conf.d/upstream.conf
# Lets trigger the NGINX reload
EE_DEBUG_NGINX="--nginx"
else
ee_lib_echo "PHP5-FPM slow log already enabled"
fi
else
grep 9001 /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
ee_lib_echo "Enable PHP5-FPM slow log for $EE_DOMAIN, please wait..."
sed -i "s/fastcgi_pass.*/fastcgi_pass debug;/g" /etc/nginx/sites-available/$EE_DOMAIN
# Lets trigger the NGINX reload
EE_DEBUG_NGINX="--nginx"
else
ee_lib_echo "PHP5-FPM slow log already enabled for $EE_DOMAIN"
fi
fi
}

32
src/modules/debug/ee_mod_debug_php_stop.sh

@ -1,32 +0,0 @@
# Disables PHP debug mode
function ee_mod_debug_php_stop()
{
# Lets disable PHP restart trigger
EE_DEBUG_PHP=""
if [ -z $EE_DEBUG_SITENAME ]; then
grep -B2 9001 /etc/nginx/conf.d/upstream.conf \
| grep php &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
ee_lib_echo "Disable PHP5-FPM slow log, please wait..."
sed -i "4 s/9001/9000/" /etc/nginx/conf.d/upstream.conf
# Lets trigger the NGINX reload
EE_DEBUG_NGINX="--nginx"
else
ee_lib_echo "PHP5-FPM slow log already disabled"
fi
else
grep "fastcgi_pass debug;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
ee_lib_echo "Disable PHP5-FPM slow log for $EE_DOMAIN, please wait..."
sed -i "s/fastcgi_pass.*/fastcgi_pass php;/g" /etc/nginx/sites-available/$EE_DOMAIN
# Lets trigger NGINX reload
EE_DEBUG_NGINX="--nginx"
else
ee_lib_echo "PHP5-FPM slow log already disabled for $EE_DOMAIN"
fi
fi
}
Loading…
Cancel
Save