Browse Source

Fixed #322

bugfixes
harshadyeola 10 years ago
parent
commit
98ca260069
  1. 20
      config/bash_completion.d/ee_auto.rc
  2. 54
      ee/cli/plugins/debug.py

20
config/bash_completion.d/ee_auto.rc

@ -29,7 +29,7 @@ _ee_complete()
# IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE # IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE
"debug") "debug")
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql -i --interactive --all --nginx=off --php=off --fpm=off --mysql=off --all=off " \ -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --nginx --php --fpm --mysql -i --interactive --all --import-slow-log --import-slow-log-interval= --nginx=off --php=off --fpm=off --mysql=off --all=off " \
-- $cur) ) -- $cur) )
;; ;;
@ -133,8 +133,14 @@ _ee_complete()
;; ;;
esac esac
if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] && [ "$prev" != "--nginx" ] && [ "$prev" != "--php" ] && [ "$prev" != "--fpm" ] && [ "$prev" != "--mysql" ] && [ "$prev" != "-i" ] && [ "$prev" != "--interactive" ] && [ "$prev" != "--import-slow-log" ] && [ "$prev" != "--stop" ]); then
retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off" retlist="--all --wp --rewrite -i --all=off --wp=off --rewrite=off"
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \
-W "$(echo $ret)" \
-- $cur) )
else
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log --import-slow-log-interval="
ret="${retlist[@]/$prev}" ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \
-W "$(echo $ret)" \ -W "$(echo $ret)" \
@ -196,10 +202,10 @@ _ee_complete()
elif [[ ${COMP_WORDS[2]} == "start" || ${COMP_WORDS[2]} == "reload" || ${COMP_WORDS[2]} == "restart" || ${COMP_WORDS[2]} == "stop" ]]; then elif [[ ${COMP_WORDS[2]} == "start" || ${COMP_WORDS[2]} == "reload" || ${COMP_WORDS[2]} == "restart" || ${COMP_WORDS[2]} == "stop" ]]; then
retlist="--nginx --php --mysql --postfix --memcache --dovecot" retlist="--nginx --php --mysql --postfix --memcache --dovecot"
elif [[ ${COMP_WORDS[1]} == "debug" ]]; then elif [[ ${COMP_WORDS[1]} == "debug" ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop" retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log --import-slow-log-interval="
if [[ $prev == '--mysql' ]]; then #if [[ $prev == '--mysql' ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log" # retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log --import-slow-log-interval="
fi #fi
fi fi
ret="${retlist[@]/$prev}" ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \ COMPREPLY=( $(compgen \

54
ee/cli/plugins/debug.py

@ -493,27 +493,39 @@ class EEDebugController(CementBaseController):
try: try:
if not EEShellExec.cmd_exec(self, "crontab -l | grep " if not EEShellExec.cmd_exec(self, "crontab -l | grep "
"'ee debug --import-slow-log'"): "'ee debug --import-slow-log'"):
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l " if not cron_time == 0:
"2> /dev/null | {{ cat; echo -e" EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
" \\\"#EasyEngine start MySQL " "2> /dev/null | {{ cat; echo -e"
"slow log \\n*/{0} * * * * " " \\\"#EasyEngine start MySQL "
"/usr/local/bin/ee debug" "slow log \\n*/{0} * * * * "
" --import-slow-log\\n" "/usr/local/bin/ee debug"
"#EasyEngine end MySQL slow log" " --import-slow-log\\n"
"\\\"; }} | crontab -\"" "#EasyEngine end MySQL slow log"
.format(cron_time)) "\\\"; }} | crontab -\""
.format(cron_time))
else: else:
if not EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab " if not cron_time == 0:
"-l | sed '/EasyEngine start " if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"MySQL slow " "\"crontab "
"log/!b;n;c\*\/{0} \* \* \* " "-l | sed '/EasyEngine "
"\* \/usr" "start MySQL slow "
"\/local\/bin\/ee debug " "log/!b;n;c\*\/{0} "
"--import\-slow\-log' " "\* \* \* "
"| crontab -\"" "\* \/usr"
.format(cron_time)): "\/local\/bin\/ee debug "
Log.error(self, "cron not updated") "--import\-slow\-log' "
"| crontab -\""
.format(cron_time)):
Log.error(self, "failed to update crontab entry")
else:
if not EEShellExec.cmd_exec(self, "/bin/bash -c "
"\"crontab "
"-l | sed '/EasyEngine "
"start MySQL slow "
"log/,+2d'"
"| crontab -\""
.format(cron_time)):
Log.error(self, "failed to remove crontab entry")
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, str(e)) Log.debug(self, str(e))
@ -632,7 +644,7 @@ class EEDebugController(CementBaseController):
Log.error(self, "MySQL slow log file not found," Log.error(self, "MySQL slow log file not found,"
" so not imported slow logs") " so not imported slow logs")
else: else:
Log.error(self, " Anemometer is not installed," + Log.error(self, " Anemometer is not installed." +
Log.ENDC + " You can install Anemometer with " Log.ENDC + " You can install Anemometer with "
"this command " "this command "
+ Log.BOLD + "\n `ee stack install --utils`" + Log.BOLD + "\n `ee stack install --utils`"

Loading…
Cancel
Save