Browse Source

ee debug functions

old-stable
gau1991 11 years ago
parent
commit
7ea7c3aa1d
  1. 78
      bin/ee
  2. 10
      src/modules/debug/ee_mod_debug_interactive.sh
  3. 24
      src/modules/debug/ee_mod_debug_kill.sh
  4. 24
      src/modules/debug/ee_mod_debug_mysql_start.sh
  5. 24
      src/modules/debug/ee_mod_debug_mysql_stop.sh
  6. 15
      src/modules/debug/ee_mod_debug_nginx_rewrite_site_start.sh
  7. 15
      src/modules/debug/ee_mod_debug_nginx_rewrite_site_stop.sh
  8. 15
      src/modules/debug/ee_mod_debug_nginx_rewrite_start.sh
  9. 15
      src/modules/debug/ee_mod_debug_nginx_rewrite_stop.sh
  10. 15
      src/modules/debug/ee_mod_debug_nginx_site_start.sh
  11. 15
      src/modules/debug/ee_mod_debug_nginx_site_stop.sh
  12. 30
      src/modules/debug/ee_mod_debug_nginx_start.sh
  13. 14
      src/modules/debug/ee_mod_debug_nginx_stop.sh
  14. 14
      src/modules/debug/ee_mod_debug_php_fpm_start.sh
  15. 14
      src/modules/debug/ee_mod_debug_php_fpm_stop.sh
  16. 32
      src/modules/debug/ee_mod_debug_php_start.sh
  17. 32
      src/modules/debug/ee_mod_debug_php_stop.sh
  18. 30
      src/modules/debug/ee_mod_debug_wordpress_start.sh
  19. 16
      src/modules/debug/ee_mod_debug_wordpress_stop.sh

78
bin/ee

@ -557,7 +557,7 @@ ee_mod_delete_nginxconf()
fi
}
DEBUG_NGINX()
ee_mod_debug_nginx_start()
{
# Lets Disable Nginx Reload Trigger
EE_DEBUG_NGINX=""
@ -568,16 +568,16 @@ DEBUG_NGINX()
EE_IP_ADDRESS="0.0.0.0/0"
fi
for DEBUG_IP_ADDRESS in $(echo $EE_IP_ADDRESS)
for ee_debug_ip_address in $(echo $EE_IP_ADDRESS)
do
grep "debug_connection $DEBUG_IP_ADDRESS" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
grep "debug_connection $ee_debug_ip_address" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]
then
# Enable Debug Connection
ee_lib_echo "Setting Up Nginx Debug Connection, Please Wait..."
# EasyEngine Found New IP Address Which Is Not Present In nginx.conf
sed -i "/events {/a \\\t$(echo debug_connection $DEBUG_IP_ADDRESS\;)" /etc/nginx/nginx.conf
sed -i "/events {/a \\\t$(echo debug_connection $ee_debug_ip_address\;)" /etc/nginx/nginx.conf
# Lets Trigger The Nginx Reload
EE_DEBUG_NGINX="--nginx"
@ -590,7 +590,7 @@ DEBUG_NGINX()
fi
}
DEBUG_NGINX_STOP()
ee_mod_debug_nginx_stop()
{
grep "debug_connection" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]
@ -604,7 +604,7 @@ DEBUG_NGINX_STOP()
fi
}
DEBUG_NGINX_REWRITE()
ee_mod_debug_nginx_rewrite_start()
{
grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]
@ -619,7 +619,7 @@ DEBUG_NGINX_REWRITE()
fi
}
DEBUG_NGINX_REWRITE_STOP()
ee_mod_debug_nginx_rewrite_stop()
{
grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]
@ -634,7 +634,7 @@ DEBUG_NGINX_REWRITE_STOP()
fi
}
DEBUG_NGINX_SITE()
ee_mod_debug_nginx_site_start()
{
grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]
@ -649,7 +649,7 @@ DEBUG_NGINX_SITE()
fi
}
DEBUG_NGINX_SITE_STOP()
ee_mod_debug_nginx_site_stop()
{
grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]
@ -664,7 +664,7 @@ DEBUG_NGINX_SITE_STOP()
fi
}
DEBUG_NGINX_REWRITE_SITE()
ee_mod_nginx_rewrite_site_start()
{
grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]
@ -679,7 +679,7 @@ DEBUG_NGINX_REWRITE_SITE()
fi
}
DEBUG_NGINX_REWRITE_SITE_STOP()
ee_mod_nginx_rewrite_site_stop()
{
grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]
@ -694,7 +694,7 @@ DEBUG_NGINX_REWRITE_SITE_STOP()
fi
}
DEBUG_PHP()
ee_mod_debug_php_start()
{
# Lets Disable PHP Restart Trigger
EE_DEBUG_PHP=""
@ -727,7 +727,7 @@ DEBUG_PHP()
fi
}
DEBUG_PHP_STOP()
ee_mod_debug_php_stop()
{
# Lets Disable PHP Restart Trigger
EE_DEBUG_PHP=""
@ -760,7 +760,7 @@ DEBUG_PHP_STOP()
fi
}
DEBUG_PHP_FPM()
ee_mod_debug_php_fpm_start()
{
grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]
@ -774,7 +774,7 @@ DEBUG_PHP_FPM()
fi
}
DEBUG_PHP_FPM_STOP()
ee_mod_debug_php_fpm_stop()
{
grep "log_level = notice" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]
@ -788,7 +788,7 @@ DEBUG_PHP_FPM_STOP()
fi
}
DEBUG_MYSQL()
ee_mod_debug_mysql_start()
{
# Collect MySQL Login Details
MYSQLROOT
@ -815,7 +815,7 @@ DEBUG_MYSQL()
fi
}
DEBUG_MYSQL_STOP()
ee_mod_debug_mysql_stop()
{
# Collect MySQL Login Details
MYSQLROOT
@ -842,7 +842,7 @@ DEBUG_MYSQL_STOP()
fi
}
DEBUG_WORDPRESS()
ee_mod_debug_wordpress_start()
{
if [ -e /var/www/$EE_DOMAIN/wp-config.php ]
then
@ -877,7 +877,7 @@ DEBUG_WORDPRESS()
fi
}
DEBUG_WORDPRESS_STOP()
ee_mod_debug_wordpress_stop()
{
grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]
@ -893,7 +893,7 @@ DEBUG_WORDPRESS_STOP()
fi
}
DEBUG_KILL()
ee_mod_debug_kill()
{
if [ "$EE_DEBUG" = "--start" ]
then
@ -915,9 +915,9 @@ DEBUG_KILL()
# Successfull Exit
exit 0;
}
trap "DEBUG_KILL" EXIT
trap "ee_mod_debug_kill" EXIT
DEBUG_INTERACTIVE()
ee_mod_debug_interactive()
{
if [ -z "$EE_DEBUG_SITENAME" ]
then
@ -1761,7 +1761,7 @@ then
if [ "$EE_DEBUG_NGINX" = "--nginx" ]
then
# Debug Nginx
DEBUG_NGINX
ee_mod_debug_nginx_start
# Log Message
LOGMESSAGE="/var/log/nginx/*.error.log"
@ -1770,7 +1770,7 @@ then
if [ "$EE_DEBUG_REWRITE" = "--rewrite" ]
then
# Debug Nginx Rewrite Logs
DEBUG_NGINX_REWRITE
ee_mod_debug_nginx_rewrite_start
# Log Message
LOGMESSAGE="$LOGMESSAGE /var/log/nginx/*.error.log"
@ -1790,7 +1790,7 @@ then
if [ "$EE_DEBUG_NGINX" = "--nginx" ]
then
# Debug Nginx
DEBUG_NGINX_SITE
ee_mod_debug_nginx_site_start
# Log Message
LOGMESSAGE="/var/www/$EE_DOMAIN/logs/error.log"
@ -1799,7 +1799,7 @@ then
if [ "$EE_DEBUG_REWRITE" = "--rewrite" ]
then
# Debug Nginx Rewrite Logs
DEBUG_NGINX_REWRITE_SITE
ee_mod_nginx_rewrite_site_start
# Log Message
LOGMESSAGE="$LOGMESSAGE /var/log/$EE_DOMAIN/logs/error.log"
@ -1808,7 +1808,7 @@ then
if [ "$EE_DEBUG_WP" = "--wp" ]
then
# Debug WordPress Debug Log
DEBUG_WORDPRESS
ee_mod_debug_wordpress_start
# Log Message
LOGMESSAGE="$LOGMESSAGE /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log"
@ -1819,7 +1819,7 @@ then
if [ "$EE_DEBUG_PHP" = "--php" ]
then
# Debug PHP
DEBUG_PHP
ee_mod_debug_php_start
# Log Message
LOGMESSAGE="$LOGMESSAGE /var/log/php5/slow.log"
@ -1828,7 +1828,7 @@ then
if [ "$EE_DEBUG_FPM" = "--fpm" ]
then
# Debug PHP FPM
DEBUG_PHP_FPM
ee_mod_debug_php_fpm_start
# Log Message
LOGMESSAGE="$LOGMESSAGE /var/log/php5/fpm.log"
@ -1837,7 +1837,7 @@ then
if [ "$EE_DEBUG_MYSQL" = "--mysql" ]
then
# Debug MySQL Slow Query
DEBUG_MYSQL
ee_mod_debug_mysql_start
# Log Message
LOGMESSAGE="$LOGMESSAGE /var/log/mysql/slow.log"
@ -1862,13 +1862,13 @@ then
if [ "$EE_DEBUG_NGINX" = "--nginx" ]
then
# Debug Nginx
DEBUG_NGINX_STOP
ee_mod_debug_nginx_stop
fi
if [ "$EE_DEBUG_REWRITE" = "--rewrite" ]
then
# Debug Nginx Rewrite Logs
DEBUG_NGINX_REWRITE_STOP
ee_mod_debug_nginx_rewrite_stop
fi
else
@ -1880,19 +1880,19 @@ then
if [ "$EE_DEBUG_NGINX" = "--nginx" ]
then
# Debug Nginx
DEBUG_NGINX_SITE_STOP
ee_mod_debug_nginx_site_stop
fi
if [ "$EE_DEBUG_REWRITE" = "--rewrite" ]
then
# Debug Nginx Rewrite Logs
DEBUG_NGINX_REWRITE_SITE_STOP
ee_mod_nginx_rewrite_site_stop
fi
if [ "$EE_DEBUG_WP" = "--wp" ]
then
# Debug WordPress Debug Log
DEBUG_WORDPRESS_STOP
ee_mod_debug_wordpress_stop
fi
fi
@ -1900,19 +1900,19 @@ then
if [ "$EE_DEBUG_PHP" = "--php" ]
then
# Debug PHP
DEBUG_PHP_STOP
ee_mod_debug_php_stop
fi
if [ "$EE_DEBUG_FPM" = "--fpm" ]
then
# Debug PHP FPM
DEBUG_PHP_FPM_STOP
ee_mod_debug_php_fpm_stop
fi
if [ "$EE_DEBUG_MYSQL" = "--mysql" ]
then
# Debug MySQL Slow Query
DEBUG_MYSQL_STOP
ee_mod_debug_mysql_stop
fi
fi
@ -1939,7 +1939,7 @@ then
if [ "$EE_DEBUG_INTERACTIVE" = "-i" ]
then
# Lets Start Debug In Interactive Mode
DEBUG_INTERACTIVE
ee_mod_debug_interactive
elif [ "$EE_DEBUG_INTERACTIVE" != "-i" ] && [ "$EE_DEBUG" != "--stop" ]
then
ee_lib_echo_info "tail -f $LOGMESSAGE"

10
src/modules/debug/ee_mod_debug_interactive.sh

@ -0,0 +1,10 @@
#Enables debug in interactive mode
function ee_mod_debug_interactive()
{
if [ -z "$EE_DEBUG_SITENAME" ]; then
tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log
else
tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log
fi
}

24
src/modules/debug/ee_mod_debug_kill.sh

@ -0,0 +1,24 @@
function ee_mod_debug_kill()
{
if [ "$EE_DEBUG" = "--start" ]; then
if [ -z "$EE_DEBUG_SITENAME" ]; then
ee debug --stop
else
ee debug --stop $EE_DEBUG_SITENAME
fi
fi
# Unset trap so we don't get infinite loop
trap - EXIT
# Flush file system buffers
# More details: info coreutils 'sync invocation'
sync
# Successfull exit
exit 0;
}
trap "ee_mod_debug_kill" EXIT

24
src/modules/debug/ee_mod_debug_mysql_start.sh

@ -0,0 +1,24 @@
# Enables MySQL debug mode
function ee_mod_debug_mysql_start()
{
# Check MySql slow logs is on
#grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Enable MySQL slow logs
ee_lib_echo "Setting up MySQL slow log, please wait..."
mysql -u -e "set global slow_query_log = 'ON';"
mysql -u -e "set global slow_query_log_file = '/var/log/mysql/slow.log';"
mysql -u -e "set global long_query_time=2;"
mysql -u -e "set global log_queries_not_using_indexes = 'ON';"
#sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf
#sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf
#sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf
else
# Lets disable MySQL restart trigger
#EE_DEBUG_MYSQL=""
ee_lib_echo "MySQL slow log already enabled"
fi
}

24
src/modules/debug/ee_mod_debug_mysql_stop.sh

@ -0,0 +1,24 @@
# MySQL debug mode
function ee_mod_debug_mysql_stop()
{
# Check MySql slow logs is off
#grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
# Disable MySQL slow logs
ee_lib_echo "Stopping MySQL slow log, please wait..."
mysql -e "set global slow_query_log = 'OFF';"
mysql -e "set global slow_query_log_file = '/var/log/mysql/slow.log';"
mysql -e "set global long_query_time=10;"
mysql -e "set global log_queries_not_using_indexes = 'OFF';"
#sed -i "/slow-query-log/d" /etc/mysql/my.cnf
#sed -i "s/long_query_time/#long_query_time/" /etc/mysql/my.cnf
#sed -i "s/log-queries-not-using-indexes/#log-queries-not-using-indexes/" /etc/mysql/my.cnf
else
# Lets disable MySQL restart trigger
#EE_DEBUG_MYSQL=""
ee_lib_echo "MySQL slow log already disable"
fi
}

15
src/modules/debug/ee_mod_debug_nginx_rewrite_site_start.sh

@ -0,0 +1,15 @@
# Enables NGINX rewrite_log mode for $EE_DOMAIN
function ee_mod_nginx_rewrite_site_start()
{
grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Enable NGINX rewrite logs
ee_lib_echo "Setting up NGINX rewrite logs for $EE_DOMAIN"
sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN
else
# Lets disable NGINX reload trigger
EE_DEBUG_REWRITE=""
ee_lib_echo "Rewrites logs already on for $EE_DOMAIN"
fi
}

15
src/modules/debug/ee_mod_debug_nginx_rewrite_site_stop.sh

@ -0,0 +1,15 @@
# Disables NGINX rewrite_log mode for $EE_DOMAIN
function ee_mod_debug_nginx_rewrite_site_stop()
{
grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
# Disable NGINX rewrite logs
ee_lib_echo "Stopping up NGINX rewrite logs for $EE_DOMAIN"
sed -i "/rewrite_log.*/d" /etc/nginx/sites-available/$EE_DOMAIN
else
# Lets disable NGINX reload trigger
EE_DEBUG_REWRITE=""
ee_lib_echo "Rewrites logs already stop for $EE_DOMAIN"
fi
}

15
src/modules/debug/ee_mod_debug_nginx_rewrite_start.sh

@ -0,0 +1,15 @@
# Enables NGINX rewrite_log mode
function ee_mod_debug_nginx_rewrite_start()
{
grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Enable NGINX rewrite logs
ee_lib_echo "Setting up NGINX rewrite logs, please wait..."
sed -i '/http {/a \\trewrite_log on;' /etc/nginx/nginx.conf
else
# Lets disable NGINX reload trigger
EE_DEBUG_REWRITE=""
ee_lib_echo "NGINX rewrites logs already on"
fi
}

15
src/modules/debug/ee_mod_debug_nginx_rewrite_stop.sh

@ -0,0 +1,15 @@
# Disables NGINX rewrite_log mode
function ee_mod_debug_nginx_rewrite_stop()
{
grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
# Disable NGINX rewrite logs
ee_lib_echo "Stopping NGINX Rewrite Logs, Please Wait..."
sed -i "/rewrite_log.*/d" /etc/nginx/nginx.conf
else
# Lets disable NGINX reload trigger
EE_DEBUG_REWRITE=""
ee_lib_echo "NGINX rewrites logs already stop"
fi
}

15
src/modules/debug/ee_mod_debug_nginx_site_start.sh

@ -0,0 +1,15 @@
# Enable NGINX site debug mode
function ee_mod_debug_nginx_site_start()
{
grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Enable NGINX debug log
ee_lib_echo "Setting up $EE_DOMAIN error logs in debugging mode,please wait..."
sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$EE_DOMAIN
else
# Lets disable NGINX reload trigger
EE_DEBUG_NGINX=""
ee_lib_echo "Already started $EE_DOMAIN error logs in debugging mode"
fi
}

15
src/modules/debug/ee_mod_debug_nginx_site_stop.sh

@ -0,0 +1,15 @@
# Disables NGINX site debug mode
function ee_mod_debug_nginx_site_stop()
{
grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
# Disable NGINX debug log
ee_lib_echo "Disable $EE_DOMAIN error logs in debugging mode,please wait..."
sed -i "s/error.log debug;/error.log;/" /etc/nginx/sites-available/$EE_DOMAIN
else
# Lets disable NGINX reload trigger
EE_DEBUG_NGINX=""
ee_lib_echo "Already stopped $EE_DOMAIN error logs in debugging mode"
fi
}

30
src/modules/debug/ee_mod_debug_nginx_start.sh

@ -0,0 +1,30 @@
# Enables NGINX debug mode
function ee_mod_debug_nginx_start()
{
# Lets disable NGINX reload trigger
EE_DEBUG_NGINX=""
if [ -z "$EE_IP_ADDRESS" ]; then
#read -p "Enter the single IP address for debugging: " EE_IP_ADDRESS
EE_IP_ADDRESS="0.0.0.0/0"
fi
for ee_debug_ip_address in $(echo $EE_IP_ADDRESS); do
grep "debug_connection $ee_debug_ip_address" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Enable debug connection
ee_lib_echo "Setting up NGINX debug connection, please wait..."
# EasyEngine found new IP address which is not present in nginx.conf
sed -i "/events {/a \\\t$(echo debug_connection $ee_debug_ip_address\;)" /etc/nginx/nginx.conf
# Lets trigger the NGINX reload
EE_DEBUG_NGINX="--nginx"
fi
done
if [ -z "$EE_DEBUG_NGINX" ]; then
ee_lib_echo "NGINX debug connection already enabled"
fi
}

14
src/modules/debug/ee_mod_debug_nginx_stop.sh

@ -0,0 +1,14 @@
# Disables NGINX debug mode
function ee_mod_debug_nginx_stop()
{
grep "debug_connection" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
ee_lib_echo "Stopping NGINX debug connection, please wait..."
sed -i "/debug_connection.*/d" /etc/nginx/nginx.conf
else
# Lets disable NGINX reload trigger
EE_DEBUG_NGINX=""
ee_lib_echo "NGINX debug connection already stopped"
fi
}

14
src/modules/debug/ee_mod_debug_php_fpm_start.sh

@ -0,0 +1,14 @@
# Enables PHP5-FPM debug mode
function ee_mod_debug_php_fpm_start()
{
grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Enable PHP5-FPM error logs in debug mode
ee_lib_echo "Setting up PHP5-FPM log level in debug mode, please wait..."
sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf
else
EE_DEBUG_FPM=""
ee_lib_echo "PHP5-FPM log level is already in debug mode"
fi
}

14
src/modules/debug/ee_mod_debug_php_fpm_stop.sh

@ -0,0 +1,14 @@
# Disables PHP5-FPM debug mode
function ee_mod_debug_php_fpm_stop()
{
grep "log_level = notice" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Disable PHP5-FPM error logs in debug mode
ee_lib_echo "Stopping PHP5-FPM log level in debug mode, please wait..."
sed -i "s/log_level = debug/log_level = notice/" /etc/php5/fpm/php-fpm.conf
else
EE_DEBUG_FPM=""
ee_lib_echo "PHP5-FPM log level already in notice (default) mode"
fi
}

32
src/modules/debug/ee_mod_debug_php_start.sh

@ -0,0 +1,32 @@
# 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

@ -0,0 +1,32 @@
# 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
}

30
src/modules/debug/ee_mod_debug_wordpress_start.sh

@ -0,0 +1,30 @@
# Enables WordPress debug mode
function ee_mod_debug_wordpress_start()
{
if [ -e /var/www/$EE_DOMAIN/wp-config.php ]; then
grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG
if [ $? -ne 0 ]; then
# Debug WordPress
ee_lib_echo "Start WordPress debug logs for $EE_DOMAIN"
# Create debug.log & change permission
touch /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log
chown $EE_PHP_USER:$EE_PHP_USER /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log
# Turn on debug
sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" \
/var/www/$EE_DOMAIN/wp-config.php
# Install developer plugin
cd /var/www/$EE_DOMAIN/htdocs/
ee_lib_echo "Installing developer plugin, please wait..."
wp plugin --allow-root install developer &>> $EE_COMMAND_LOG \
|| ee_lib_error "Unable to install developer plugin, exit status = " $?
else
ee_lib_echo "WordPress debug log already started for $EE_DOMAIN"
fi
else
ee_lib_echo_fail "Unable to find wp-config.php file, seems like not WordPress site"
fi
}

16
src/modules/debug/ee_mod_debug_wordpress_stop.sh

@ -0,0 +1,16 @@
# Disables WordPress debug mode
function ee_mod_debug_wordpress_stop()
{
grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG
if [ $? -eq 0 ]; then
# Stop debug WordPress
ee_lib_echo "Stopping WordPress debug logs for $EE_DOMAIN"
sed -i "s/define('WP_DEBUG', true);/define('WP_DEBUG', false);/" /var/www/$EE_DOMAIN/wp-config.php
sed -i "/define('WP_DEBUG_DISPLAY', false);/d" /var/www/$EE_DOMAIN/wp-config.php
sed -i "/define('WP_DEBUG_LOG', true);/d" /var/www/$EE_DOMAIN/wp-config.php
sed -i "/define('SAVEQUERIES', true);/d" /var/www/$EE_DOMAIN/wp-config.php
else
ee_lib_echo "WordPress debug log already stopped for $EE_DOMAIN"
fi
}
Loading…
Cancel
Save