def default(self): """Default function of debug""" self.start = True self.interactive = False self.msg = [] self.trigger_nginx = False self.trigger_php = False if self.app.pargs.stop: self.start = False if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.site_name)): self.app.pargs.nginx = True self.app.pargs.php = True self.app.pargs.fpm = True self.app.pargs.mysql = True self.app.pargs.rewrite = True if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and self.app.pargs.site_name): self.app.pargs.nginx = True self.app.pargs.wp = True self.app.pargs.rewrite = True if self.app.pargs.nginx: self.debug_nginx() if self.app.pargs.php: self.debug_php() if self.app.pargs.fpm: self.debug_fpm() if self.app.pargs.mysql: # MySQL debug will not work for remote MySQL if EEVariables.ee_mysql_host is "localhost": self.debug_mysql() else: Log.warn(self, "Remote MySQL found, EasyEngine will not " "enable remote debug") if self.app.pargs.wp: self.debug_wp() if self.app.pargs.rewrite: self.debug_rewrite() if self.app.pargs.interactive: self.interactive = True # Reload Nginx if self.trigger_nginx: EEService.reload_service(self, 'nginx') # Reload PHP if self.trigger_php: EEService.reload_service(self, 'php5-fpm') if len(self.msg) > 0: if not self.app.pargs.interactive: disp_msg = ' '.join(self.msg) Log.info(self, "Use following command to check debug logs:\n" + Log.ENDC + "tail -f {0}".format(disp_msg)) else: signal.signal(signal.SIGINT, self.signal_handler) watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) logwatch(self, watch_list)
def default(self): """Default function of log show""" self.msg = [] if self.app.pargs.php: self.app.pargs.nginx = True if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.access) and (not self.app.pargs.wp) and (not self.app.pargs.site_name)): self.app.pargs.nginx = True self.app.pargs.fpm = True self.app.pargs.mysql = True self.app.pargs.access = True if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.access) and (not self.app.pargs.wp) and (self.app.pargs.site_name)): self.app.pargs.nginx = True self.app.pargs.wp = True self.app.pargs.access = True self.app.pargs.mysql = True if self.app.pargs.nginx and (not self.app.pargs.site_name): self.msg = self.msg + ["/var/log/nginx/*error.log"] if self.app.pargs.access and (not self.app.pargs.site_name): self.msg = self.msg + ["/var/log/nginx/*access.log"] if self.app.pargs.fpm: 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": if os.path.isfile('/var/log/mysql/mysql-slow.log'): self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] else: Log.info(self, "MySQL slow-log not found, skipped") else: Log.warn( self, "Remote MySQL found, EasyEngine is not able to" "show MySQL log file") if self.app.pargs.site_name: webroot = "{0}{1}".format(EEVariables.ee_webroot, self.app.pargs.site_name) if not os.path.isdir(webroot): Log.error(self, "Site not present, quitting") if self.app.pargs.access: self.msg = self.msg + [ "{0}/{1}/logs/access.log".format(EEVariables.ee_webroot, self.app.pargs.site_name) ] if self.app.pargs.nginx: self.msg = self.msg + [ "{0}/{1}/logs/error.log".format(EEVariables.ee_webroot, self.app.pargs.site_name) ] if self.app.pargs.wp: if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)): if not os.path.isfile( '{0}/logs/debug.log'.format(webroot)): if not os.path.isfile('{0}/htdocs/wp-content/debug.log' .format(webroot)): open("{0}/htdocs/wp-content/debug.log".format( webroot), encoding='utf-8', mode='a').close() EEShellExec.cmd_exec( self, "chown {1}: {0}/htdocs/" "wp-content/debug.log" "".format(webroot, EEVariables.ee_php_user)) # create symbolic link for debug log EEFileUtils.create_symlink(self, [ "{0}/htdocs/wp-content/" "debug.log".format(webroot), '{0}/logs/debug.log'.format(webroot) ]) self.msg = self.msg + [ "{0}/{1}/logs/debug.log".format( EEVariables.ee_webroot, self.app.pargs.site_name) ] else: Log.info( self, "Site is not WordPress site, skipping " "WordPress logs") watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) logwatch(self, watch_list)
def default(self): """Default function of debug""" # self.start = True self.interactive = False self.msg = [] self.trigger_nginx = False self.trigger_php = False if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.php7) and (not self.app.pargs.fpm) and (not self.app.pargs.fpm7) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.all) and (not self.app.pargs.site_name) and (not self.app.pargs.import_slow_log) and (not self.app.pargs.interval)): if self.app.pargs.stop or self.app.pargs.start: print("--start/stop option is deprecated since ee3.0.5") self.app.args.print_help() else: self.app.args.print_help() if self.app.pargs.import_slow_log: self.import_slow_log() if self.app.pargs.interval: try: cron_time = int(self.app.pargs.interval) except Exception as e: cron_time = 5 try: if not EEShellExec.cmd_exec(self, "crontab -l | grep " "'ee debug --import-slow-log'"): if not cron_time == 0: Log.info(self, "setting up crontab entry," " please wait...") 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 debug" " --import-slow-log\\n" "#EasyEngine end MySQL slow log" "\\\"; }} | crontab -\"" .format(cron_time)) else: if not cron_time == 0: Log.info(self, "updating crontab entry," " please wait...") if not EEShellExec.cmd_exec(self, "/bin/bash -c " "\"crontab " "-l | sed '/EasyEngine " "start MySQL slow " "log/!b;n;c\*\/{0} " "\* \* \* " "\* \/usr" "\/local\/bin\/ee debug " "--import\-slow\-log' " "| crontab -\"" .format(cron_time)): Log.error(self, "failed to update crontab entry") else: Log.info(self, "removing crontab entry," " please wait...") 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: Log.debug(self, str(e)) if self.app.pargs.all == 'on': if self.app.pargs.site_name: self.app.pargs.wp = 'on' self.app.pargs.nginx = 'on' self.app.pargs.php = 'on' self.app.pargs.fpm = 'on' if (EEVariables.ee_platform_codename == 'trusty' or EEVariables.ee_platform_codename == 'xenial') and EEAptGet.is_installed(self,'php7.0-fpm'): self.app.pargs.php7 = 'on' self.app.pargs.fpm7 = 'on' self.app.pargs.mysql = 'on' self.app.pargs.rewrite = 'on' if self.app.pargs.all == 'off': if self.app.pargs.site_name: self.app.pargs.wp = 'off' self.app.pargs.nginx = 'off' self.app.pargs.php = 'off' self.app.pargs.fpm = 'off' if (EEVariables.ee_platform_codename == 'trusty' or EEVariables.ee_platform_codename == 'xenial') and EEAptGet.is_installed(self,'php7.0-fpm'): self.app.pargs.php7 = 'off' self.app.pargs.fpm7 = 'off' self.app.pargs.mysql = 'off' self.app.pargs.rewrite = 'off' if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.php7) and (not self.app.pargs.fpm) and (not self.app.pargs.fpm7) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and self.app.pargs.site_name): self.app.args.print_help() # self.app.pargs.nginx = 'on' # self.app.pargs.wp = 'on' # self.app.pargs.rewrite = 'on' if self.app.pargs.nginx: self.debug_nginx() if self.app.pargs.php: self.debug_php() if self.app.pargs.fpm: self.debug_fpm() if self.app.pargs.php7: self.debug_php7() if self.app.pargs.fpm7: self.debug_fpm7() if self.app.pargs.mysql: # MySQL debug will not work for remote MySQL if EEVariables.ee_mysql_host is "localhost": self.debug_mysql() else: Log.warn(self, "Remote MySQL found, EasyEngine will not " "enable remote debug") if self.app.pargs.wp: self.debug_wp() if self.app.pargs.rewrite: self.debug_rewrite() if self.app.pargs.interactive: self.interactive = True # Reload Nginx if self.trigger_nginx: EEService.reload_service(self, 'nginx') # Reload PHP if self.trigger_php: if (EEVariables.ee_platform_codename == 'trusty' or EEVariables.ee_platform_codename == 'xenial'): if EEAptGet.is_installed(self,'php5.6-fpm'): EEService.restart_service(self, 'php5.6-fpm') if EEAptGet.is_installed(self,'php7.0-fpm'): EEService.restart_service(self, 'php7.0-fpm') else: EEService.restart_service(self, 'php5-fpm') if len(self.msg) > 0: if not self.app.pargs.interactive: disp_msg = ' '.join(self.msg) Log.info(self, "Use following command to check debug logs:\n" + Log.ENDC + "tail -f {0}".format(disp_msg)) else: signal.signal(signal.SIGINT, self.signal_handler) watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) logwatch(self, watch_list)
def default(self): """Default function of debug""" # self.start = True self.interactive = False self.msg = [] self.trigger_nginx = False self.trigger_php = False if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.all) and (not self.app.pargs.site_name)): if self.app.pargs.stop or self.app.pargs.start: print("--start/stop option is deprecated since ee3.0.5") self.app.args.print_help() else: self.app.args.print_help() if self.app.pargs.all == 'on': if self.app.pargs.site_name: self.app.pargs.wp = 'on' self.app.pargs.nginx = 'on' self.app.pargs.php = 'on' self.app.pargs.fpm = 'on' self.app.pargs.mysql = 'on' self.app.pargs.rewrite = 'on' if self.app.pargs.all == 'off': if self.app.pargs.site_name: self.app.pargs.wp = 'off' self.app.pargs.nginx = 'off' self.app.pargs.php = 'off' self.app.pargs.fpm = 'off' self.app.pargs.mysql = 'off' self.app.pargs.rewrite = 'off' if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and self.app.pargs.site_name): self.app.args.print_help() # self.app.pargs.nginx = 'on' # self.app.pargs.wp = 'on' # self.app.pargs.rewrite = 'on' if self.app.pargs.nginx: self.debug_nginx() if self.app.pargs.php: self.debug_php() if self.app.pargs.fpm: self.debug_fpm() if self.app.pargs.mysql: # MySQL debug will not work for remote MySQL if EEVariables.ee_mysql_host is "localhost": self.debug_mysql() else: Log.warn(self, "Remote MySQL found, EasyEngine will not " "enable remote debug") if self.app.pargs.wp: self.debug_wp() if self.app.pargs.rewrite: self.debug_rewrite() if self.app.pargs.interactive: self.interactive = True # Reload Nginx if self.trigger_nginx: EEService.reload_service(self, 'nginx') # Reload PHP if self.trigger_php: EEService.restart_service(self, 'php5-fpm') if len(self.msg) > 0: if not self.app.pargs.interactive: disp_msg = ' '.join(self.msg) Log.info(self, "Use following command to check debug logs:\n" + Log.ENDC + "tail -f {0}".format(disp_msg)) else: signal.signal(signal.SIGINT, self.signal_handler) watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) logwatch(self, watch_list)
def default(self): """Default function of debug""" self.start = True self.interactive = False self.msg = [] self.trigger_nginx = False self.trigger_php = False if self.app.pargs.stop: self.start = False if ( (not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.site_name) ): self.app.pargs.nginx = True self.app.pargs.php = True self.app.pargs.fpm = True self.app.pargs.mysql = True self.app.pargs.rewrite = True if ( (not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and self.app.pargs.site_name ): self.app.pargs.nginx = True self.app.pargs.wp = True self.app.pargs.rewrite = True if self.app.pargs.nginx: self.debug_nginx() if self.app.pargs.php: self.debug_php() if self.app.pargs.fpm: self.debug_fpm() if self.app.pargs.mysql: # MySQL debug will not work for remote MySQL if EEVariables.ee_mysql_host is "localhost": self.debug_mysql() else: Log.warn(self, "Remote MySQL found, EasyEngine will not " "enable remote debug") if self.app.pargs.wp: self.debug_wp() if self.app.pargs.rewrite: self.debug_rewrite() if self.app.pargs.interactive: self.interactive = True # Reload Nginx if self.trigger_nginx: EEService.reload_service(self, "nginx") # Reload PHP if self.trigger_php: EEService.reload_service(self, "php5-fpm") if len(self.msg) > 0: if not self.app.pargs.interactive: disp_msg = " ".join(self.msg) Log.info( self, "Use following command to check debug logs:\n" + Log.ENDC + "tail -f {0}".format(disp_msg) ) else: signal.signal(signal.SIGINT, self.signal_handler) watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) logwatch(self, watch_list)
def default(self): """Default function of debug""" # self.start = True self.interactive = False self.msg = [] self.trigger_nginx = False self.trigger_php = False if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.php7) and (not self.app.pargs.fpm) and (not self.app.pargs.fpm7) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and (not self.app.pargs.all) and (not self.app.pargs.site_name) and (not self.app.pargs.import_slow_log) and (not self.app.pargs.interval)): if self.app.pargs.stop or self.app.pargs.start: print("--start/stop option is deprecated since ee3.0.5") self.app.args.print_help() else: self.app.args.print_help() if self.app.pargs.import_slow_log: self.import_slow_log() if self.app.pargs.interval: try: cron_time = int(self.app.pargs.interval) except Exception as e: cron_time = 5 try: if not EEShellExec.cmd_exec( self, "crontab -l | grep " "'ee debug --import-slow-log'"): if not cron_time == 0: Log.info(self, "setting up crontab entry," " please wait...") 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 debug" " --import-slow-log\\n" "#EasyEngine end MySQL slow log" "\\\"; }} | crontab -\"".format(cron_time)) else: if not cron_time == 0: Log.info(self, "updating crontab entry," " please wait...") if not EEShellExec.cmd_exec( self, "/bin/bash -c " "\"crontab " "-l | sed '/EasyEngine " "start MySQL slow " "log/!b;n;c\*\/{0} " "\* \* \* " "\* \/usr" "\/local\/bin\/ee debug " "--import\-slow\-log' " "| crontab -\"".format(cron_time)): Log.error(self, "failed to update crontab entry") else: Log.info(self, "removing crontab entry," " please wait...") 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: Log.debug(self, str(e)) if self.app.pargs.all == 'on': if self.app.pargs.site_name: self.app.pargs.wp = 'on' self.app.pargs.nginx = 'on' self.app.pargs.php = 'on' self.app.pargs.fpm = 'on' if (EEVariables.ee_platform_codename == 'trusty' or EEVariables.ee_platform_codename == 'bionic') and EEAptGet.is_installed(self, 'php7.2-fpm'): self.app.pargs.php7 = 'on' self.app.pargs.fpm7 = 'on' self.app.pargs.mysql = 'on' self.app.pargs.rewrite = 'on' if self.app.pargs.all == 'off': if self.app.pargs.site_name: self.app.pargs.wp = 'off' self.app.pargs.nginx = 'off' self.app.pargs.php = 'off' self.app.pargs.fpm = 'off' if (EEVariables.ee_platform_codename == 'trusty' or EEVariables.ee_platform_codename == 'bionic') and EEAptGet.is_installed(self, 'php7.2-fpm'): self.app.pargs.php7 = 'off' self.app.pargs.fpm7 = 'off' self.app.pargs.mysql = 'off' self.app.pargs.rewrite = 'off' if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.php7) and (not self.app.pargs.fpm) and (not self.app.pargs.fpm7) and (not self.app.pargs.mysql) and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) and self.app.pargs.site_name): self.app.args.print_help() # self.app.pargs.nginx = 'on' # self.app.pargs.wp = 'on' # self.app.pargs.rewrite = 'on' if self.app.pargs.nginx: self.debug_nginx() if self.app.pargs.php: self.debug_php() if self.app.pargs.fpm: self.debug_fpm() if self.app.pargs.php7: self.debug_php7() if self.app.pargs.fpm7: self.debug_fpm7() if self.app.pargs.mysql: # MySQL debug will not work for remote MySQL if EEVariables.ee_mysql_host is "localhost": self.debug_mysql() else: Log.warn( self, "Remote MySQL found, EasyEngine will not " "enable remote debug") if self.app.pargs.wp: self.debug_wp() if self.app.pargs.rewrite: self.debug_rewrite() if self.app.pargs.interactive: self.interactive = True # Reload Nginx if self.trigger_nginx: EEService.reload_service(self, 'nginx') # Reload PHP if self.trigger_php: if (EEVariables.ee_platform_codename == 'trusty' or EEVariables.ee_platform_codename == 'bionic'): if EEAptGet.is_installed(self, 'php5.6-fpm'): EEService.restart_service(self, 'php5.6-fpm') if EEAptGet.is_installed(self, 'php7.2-fpm'): EEService.restart_service(self, 'php7.2-fpm') else: EEService.restart_service(self, 'php5-fpm') if EEVariables.ee_platform_codename == 'jessie': EEService.restart_service(self, 'php7.2-fpm') if len(self.msg) > 0: if not self.app.pargs.interactive: disp_msg = ' '.join(self.msg) Log.info( self, "Use following command to check debug logs:\n" + Log.ENDC + "tail -f {0}".format(disp_msg)) else: signal.signal(signal.SIGINT, self.signal_handler) watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) logwatch(self, watch_list)
def default(self): """Default function of log show""" self.msg = [] if self.app.pargs.php: self.app.pargs.nginx = True if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.access) and (not self.app.pargs.wp) and (not self.app.pargs.site_name)): self.app.pargs.nginx = True self.app.pargs.fpm = True self.app.pargs.mysql = True self.app.pargs.access = True if ((not self.app.pargs.nginx) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) and (not self.app.pargs.access) and (not self.app.pargs.wp) and (self.app.pargs.site_name)): self.app.pargs.nginx = True self.app.pargs.wp = True self.app.pargs.access = True self.app.pargs.mysql = True if self.app.pargs.nginx and (not self.app.pargs.site_name): self.msg = self.msg + ["/var/log/nginx/*error.log"] if self.app.pargs.access and (not self.app.pargs.site_name): self.msg = self.msg + ["/var/log/nginx/*access.log"] if self.app.pargs.fpm: 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": if os.path.isfile('/var/log/mysql/mysql-slow.log'): self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] else: Log.info(self, "MySQL slow-log not found, skipped") else: Log.warn(self, "Remote MySQL found, EasyEngine is not able to" "show MySQL log file") if self.app.pargs.site_name: webroot = "{0}{1}".format(EEVariables.ee_webroot, self.app.pargs.site_name) if not os.path.isdir(webroot): Log.error(self, "Site not present, quitting") if self.app.pargs.access: self.msg = self.msg + ["{0}/{1}/logs/access.log" .format(EEVariables.ee_webroot, self.app.pargs.site_name)] if self.app.pargs.nginx: self.msg = self.msg + ["{0}/{1}/logs/error.log" .format(EEVariables.ee_webroot, self.app.pargs.site_name)] if self.app.pargs.wp: if os.path.isdir('{0}/htdocs/wp-content'.format(webroot)): if not os.path.isfile('{0}/logs/debug.log' .format(webroot)): if not os.path.isfile('{0}/htdocs/wp-content/debug.log' .format(webroot)): open("{0}/htdocs/wp-content/debug.log" .format(webroot), encoding='utf-8', mode='a').close() EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/" "wp-content/debug.log" "".format(webroot, EEVariables .ee_php_user) ) # create symbolic link for debug log EEFileUtils.create_symlink(self, ["{0}/htdocs/wp-content/" "debug.log" .format(webroot), '{0}/logs/debug.log' .format(webroot)]) self.msg = self.msg + ["{0}/{1}/logs/debug.log" .format(EEVariables.ee_webroot, self.app.pargs.site_name)] else: Log.info(self, "Site is not WordPress site, skipping " "WordPress logs") watch_list = [] for w_list in self.msg: watch_list = watch_list + glob.glob(w_list) logwatch(self, watch_list)