From 32c4bcadfb0efa2dc86a8c47a860ae5eb56e87b5 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 19 Feb 2015 19:11:05 +0530 Subject: [PATCH 01/11] added messages --- ee/cli/plugins/site.py | 4 ++-- ee/cli/plugins/site_functions.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index dae89cda..6c99e899 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -976,12 +976,12 @@ class EESiteUpdateController(CementBaseController): for msg in ee_auth: Log.info(self, Log.ENDC + msg) + display_cache_settings(self, data) if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: Log.info(self, "\n\n" + Log.ENDC + "WordPress admin user :" " {0}".format(ee_wp_creds['wp_user'])) Log.info(self, Log.ENDC + "WordPress admin password : {0}" - .format(ee_wp_creds['wp_pass']) + "\n\n") - display_cache_settings(self, data) + .format(ee_wp_creds['wp_pass']) + "\n\n") updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) Log.info(self, "Successfully updated site" " http://{0}".format(ee_domain)) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 680c5263..113682de 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -331,7 +331,7 @@ def setupwordpressnetwork(self, data): def installwp_plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - Log.debug(self, "Installing plugin {0}".format(plugin_name)) + Log.info(self, "Installing plugin {0}".format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root install " "{0}".format(plugin_name), From 0792b36c858149bf54914f5862c52d72f02171bd Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 24 Feb 2015 14:43:00 +0530 Subject: [PATCH 02/11] update cache message --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 01bec554..95347ec7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -1308,7 +1308,7 @@ class EEStackController(CementBaseController): self.pre_pref(apt_packages) if len(apt_packages): EESwap.add(self) - Log.debug(self, "Updating apt-cache") + Log.info(self, "Updating apt-cache") EEAptGet.update(self) EEAptGet.install(self, apt_packages) if len(packages): From 2b9040f5449ac7b15b9aff34cdf72e28d920eba5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 24 Feb 2015 16:44:55 +0530 Subject: [PATCH 03/11] Added ee log command, fixes #429 #406 --- config/plugins.d/log.conf | 8 +++++ ee/cli/plugins/debug.py | 23 ++++++++----- ee/cli/plugins/log.py | 72 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 config/plugins.d/log.conf create mode 100644 ee/cli/plugins/log.py diff --git a/config/plugins.d/log.conf b/config/plugins.d/log.conf new file mode 100644 index 00000000..a17893f5 --- /dev/null +++ b/config/plugins.d/log.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[log] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index a99b1a2b..5440bb2b 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -12,6 +12,7 @@ import os import configparser import glob import signal +import subprocess def debug_plugin_hook(app): @@ -160,7 +161,7 @@ class EEDebugController(CementBaseController): # PHP global debug stop else: - if EEShellExec.cmd_exec(self, "sed -n \"/upstream php {/,/}/p\" " + if EEShellExec.cmd_exec(self, " sed -n \"/upstream php {/,/}/p\" " "/etc/nginx/conf.d/upstream.conf " "| grep 9001"): Log.info(self, "Disabling PHP debug") @@ -241,13 +242,16 @@ class EEDebugController(CementBaseController): cron_time = int(self.app.pargs.interval) except Exception as e: cron_time = 5 - EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l 2> " - "/dev/null | {{ cat; echo -e" - " \\\"#EasyEngine start MySQL slow" - " log \\n*/{0} * * * * " - "/usr/local/sbin/ee import-slow-log\\" - "n#EasyEngine end MySQL slow log\\\";" - " }} | crontab -\"".format(cron_time)) + + EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l " + "2> /dev/null | {{ cat; echo -e" + " \\\"#EasyEngine start MySQL " + "slow log \\n*/{0} * * * * " + "/usr/local/bin/ee " + "import-slow-log\\n" + "#EasyEngine end MySQL slow log" + "\\\"; }} | crontab -\"" + .format(cron_time)) else: Log.info(self, "MySQL slow log is already enabled") @@ -296,7 +300,8 @@ class EEDebugController(CementBaseController): " {0}".format(wp_config)) EEShellExec.cmd_exec(self, "cd {0}/htdocs/ && wp" " plugin --allow-root install " - "developer".format(webroot)) + "developer query-monitor" + .format(webroot)) EEShellExec.cmd_exec(self, "chown -R {1}: {0}/htdocs/" "wp-content/plugins" .format(webroot, diff --git a/ee/cli/plugins/log.py b/ee/cli/plugins/log.py new file mode 100644 index 00000000..4969865b --- /dev/null +++ b/ee/cli/plugins/log.py @@ -0,0 +1,72 @@ +"""Debug Plugin for EasyEngine""" + +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from ee.core.logging import Log +from ee.cli.plugins.site_functions import logwatch +from ee.core.variables import EEVariables +import os +import glob + + +def log_plugin_hook(app): + # do something with the ``app`` object here. + pass + + +class EELogController(CementBaseController): + class Meta: + label = 'log' + description = 'Show Nginx, PHP, MySQL log file' + stacked_on = 'base' + stacked_type = 'nested' + arguments = [ + (['--all'], + dict(help='Show All logs file', action='store_true')), + (['--nginx'], + dict(help='Show Nginx logs file', action='store_true')), + (['--php'], + dict(help='Show PHP logs file', action='store_true')), + (['--mysql'], + dict(help='Show MySQL logs file', action='store_true')), + ] + + @expose(hide=True) + def default(self): + """Default function of debug""" + self.msg = [] + + if ((not self.app.pargs.nginx) and (not self.app.pargs.php) + and (not self.app.pargs.mysql)): + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + + if self.app.pargs.nginx: + self.msg = self.msg + ["/var/log/nginx/*error.log"] + if self.app.pargs.php: + open('/var/log/php5/slow.log', 'a').close() + open('/var/log/php5/fpm.log', 'a').close() + self.msg = self.msg + ['/var/log/php5/slow.log', + '/var/log/php5/fpm.log'] + if self.app.pargs.mysql: + # MySQL debug will not work for remote MySQL + if EEVariables.ee_mysql_host is "localhost": + open('/var/log/mysql/mysql-slow.log', 'a').close() + self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] + else: + Log.warn(self, "Remote MySQL found, EasyEngine is not able to" + "show MySQL log file") + + watch_list = [] + for w_list in self.msg: + watch_list = watch_list + glob.glob(w_list) + + logwatch(self, watch_list) + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EELogController) + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', log_plugin_hook) From ffb35276c1e8aa72e72c32320bd73264c3397a96 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 24 Feb 2015 16:59:41 +0530 Subject: [PATCH 04/11] Improved error handling, Added autocompletion for ee log --- config/bash_completion.d/ee_auto.rc | 6 ++++++ ee/cli/plugins/log.py | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index 0acc7fc8..7b4a8155 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -57,6 +57,12 @@ _ee_complete() -- $cur) ) ;; + "log") + COMPREPLY=( $(compgen \ + -W "--mysql --php --nginx --all" \ + -- $cur) ) + ;; + # EVERYTHING ELSE *) ;; diff --git a/ee/cli/plugins/log.py b/ee/cli/plugins/log.py index 4969865b..aa253cbd 100644 --- a/ee/cli/plugins/log.py +++ b/ee/cli/plugins/log.py @@ -52,8 +52,12 @@ class EELogController(CementBaseController): if self.app.pargs.mysql: # MySQL debug will not work for remote MySQL if EEVariables.ee_mysql_host is "localhost": - open('/var/log/mysql/mysql-slow.log', 'a').close() - self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] + if os.path.isfile('/var/log/mysql/mysql-slow.log'): + self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] + else: + Log.error(self, "Unable to find MySQL slow log file," + "Please generate it using commnad ee debug " + "--mysql") else: Log.warn(self, "Remote MySQL found, EasyEngine is not able to" "show MySQL log file") From 0eb6354c362fe031db2dd1eb2cb0cfb215475a34 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 24 Feb 2015 17:18:30 +0530 Subject: [PATCH 05/11] Improvd autocompletion --- config/bash_completion.d/ee_auto.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index 7b4a8155..e590d5f0 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -11,7 +11,7 @@ _ee_complete() # SETUP THE BASE LEVEL (everything after "ee") if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $(compgen \ - -W "stack site debug clean secure import-slow-log" \ + -W "stack site debug clean secure import-slow-log log" \ -- $cur) ) From 8f129924bff13c809f52ec2d3fd39ee9f2b5e929 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 24 Feb 2015 19:40:41 +0530 Subject: [PATCH 06/11] Fixed #442 Site create issue --- ee/cli/plugins/site.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 6c99e899..2d66bb51 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -981,7 +981,7 @@ class EESiteUpdateController(CementBaseController): Log.info(self, "\n\n" + Log.ENDC + "WordPress admin user :" " {0}".format(ee_wp_creds['wp_user'])) Log.info(self, Log.ENDC + "WordPress admin password : {0}" - .format(ee_wp_creds['wp_pass']) + "\n\n") + .format(ee_wp_creds['wp_pass']) + "\n\n") updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) Log.info(self, "Successfully updated site" " http://{0}".format(ee_domain)) @@ -1100,15 +1100,15 @@ class EESiteDeleteController(CementBaseController): 'DB_HOST').split(',')[1] .split(')')[0].strip().replace('\'', '')) try: - Log.debug(self, "dropping database {0}".format(ee_db_name)) + Log.debug(self, "dropping database `{0}`".format(ee_db_name)) EEMysql.execute(self, - "drop database {0}".format(ee_db_name), + "drop database `{0}``".format(ee_db_name), errormsg='Unable to drop database {0}' .format(ee_db_name)) if ee_db_user != 'root': - Log.debug(self, "dropping user {0}".format(ee_db_user)) + Log.debug(self, "dropping user `{0}`".format(ee_db_user)) EEMysql.execute(self, - "drop user {0}@{1}" + "drop user `{0}`@`{1}`" .format(ee_db_user, ee_db_host)) EEMysql.execute(self, "flush privileges") From fbc8639c298a72adee97740cbcd341f3d5238d1d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 24 Feb 2015 19:43:15 +0530 Subject: [PATCH 07/11] Fix #442 Site create issue --- ee/cli/plugins/site_functions.py | 74 +++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 113682de..5ab34e44 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -184,31 +184,35 @@ def setupwordpress(self, data): Log.debug(self, "Generating wp-config for WordPress Single site") Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root " + "core config " - + "--dbname={0} --dbprefix={1} --dbuser={2} " + + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' " + "--dbhost=\'{3}\' " .format(data['ee_db_name'], ee_wp_prefix, - data['ee_db_user']) + data['ee_db_user'], data['ee_db_host']) + "--dbpass= " "--extra-php< Date: Tue, 24 Feb 2015 20:00:53 +0530 Subject: [PATCH 08/11] import-slow-log autocompletion in ee debug --mysql --- config/bash_completion.d/ee_auto.rc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index e590d5f0..d7238ba7 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -153,6 +153,9 @@ _ee_complete() retlist="--nginx --php --mysql --postfix --memcache --dovecot" elif [[ ${COMP_WORDS[1]} == "debug" ]]; then retlist="--start --nginx --php --fpm --mysql -i --interactive --stop" + if [[ $prev == '--mysql' ]]; then + retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log" + fi fi ret="${retlist[@]/$prev}" COMPREPLY=( $(compgen \ From 7feac693e216f4dc84d21701d6103aa238e6798c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 24 Feb 2015 20:07:07 +0530 Subject: [PATCH 09/11] Fixed ee site delete error --- ee/cli/plugins/site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 2d66bb51..f4165605 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -1102,7 +1102,7 @@ class EESiteDeleteController(CementBaseController): try: Log.debug(self, "dropping database `{0}`".format(ee_db_name)) EEMysql.execute(self, - "drop database `{0}``".format(ee_db_name), + "drop database `{0}`".format(ee_db_name), errormsg='Unable to drop database {0}' .format(ee_db_name)) if ee_db_user != 'root': From d4aef42f82b700f3f94ab4ba8c216386c957435b Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 25 Feb 2015 12:54:11 +0530 Subject: [PATCH 10/11] logging http auth while first time site create disabled --- ee/cli/plugins/site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index f4165605..1d3cbaa5 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -513,7 +513,7 @@ class EESiteCreateController(CementBaseController): setwebrootpermissions(self, data['webroot']) if ee_auth and len(ee_auth): for msg in ee_auth: - Log.info(self, Log.ENDC + msg) + Log.info(self, Log.ENDC + msg, log=False) if data['wp']: Log.info(self, Log.ENDC + "WordPress admin user :" From f097cbbf41c5ad6b4224b52600c2e057ffde1f55 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 25 Feb 2015 14:48:43 +0530 Subject: [PATCH 11/11] Changed version --- ee/core/variables.py | 2 +- install | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index f481709e..6df38377 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -12,7 +12,7 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine version - ee_version = "3.0.3" + ee_version = "3.0.4" # EasyEngine packages versions ee_wp_cli = "0.18.0" diff --git a/install b/install index d6834b33..55334045 100644 --- a/install +++ b/install @@ -5,7 +5,7 @@ # to update current EasyEngine from 2.x to 3.x old_ee_version="2.2.3" -new_ee_version="3.0.3" +new_ee_version="3.0.4" branch=$1 # Define echo function diff --git a/setup.py b/setup.py index 60d3ff50..2153842f 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ except Exception as e: os.system("git config --global user.email {0}".format(ee_email)) setup(name='ee', - version='3.0.3', + version='3.0.4', description=long_description, long_description=long_description, classifiers=[],