feat: convert WordOps from Nginx to OpenLiteSpeed + LSPHP + LSCache
Complete conversion of the WordOps stack from Nginx + PHP-FPM to OpenLiteSpeed + LSPHP + LSCache. This is a full rewrite across all 7 phases of the codebase: - Foundation: OLS paths, variables, services, removed pynginxconfig dep - Templates: 11 new OLS mustache templates, removed nginx-specific ones - Stack: stack_pref, stack, stack_services, stack_upgrade, stack_migrate - Site: site_functions, site, site_create, site_update - Plugins: debug, info, log, clean rewritten for OLS - SSL/ACME: acme.sh deploy uses lswsctrl, OLS vhssl blocks - Other: secure, backup, clone, install script Additional features: - Debian 13 (trixie) support - PHP 8.5 support - WP Fort Knox mu-plugin integration (wo secure --lockdown/--unlock) - --nginx CLI flag preserved for backward compatibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
"""Debug Plugin for WordOps"""
|
||||
|
||||
import configparser
|
||||
import glob
|
||||
import os
|
||||
import signal
|
||||
|
||||
from cement.core.controller import CementBaseController, expose
|
||||
from pynginxconfig import NginxConfig
|
||||
|
||||
from wo.cli.plugins.site_functions import logwatch
|
||||
from wo.core.aptget import WOAptGet
|
||||
from wo.core.fileutils import WOFileUtils
|
||||
from wo.core.logging import Log
|
||||
from wo.core.mysql import WOMysql
|
||||
@@ -37,24 +34,8 @@ class WODebugController(CementBaseController):
|
||||
dict(help='Import MySQL slow log to Anemometer database',
|
||||
action='store_true')),
|
||||
(['--nginx'],
|
||||
dict(help='start/stop debugging nginx server '
|
||||
'configuration for site',
|
||||
action='store' or 'store_const',
|
||||
choices=('on', 'off'), const='on', nargs='?')),
|
||||
(['--php'],
|
||||
dict(help='start/stop debugging server PHP 7.2 configuration',
|
||||
action='store' or 'store_const',
|
||||
choices=('on', 'off'), const='on', nargs='?')),
|
||||
(['--fpm'],
|
||||
dict(help='start/stop debugging fastcgi configuration',
|
||||
action='store' or 'store_const',
|
||||
choices=('on', 'off'), const='on', nargs='?')),
|
||||
(['--php73'],
|
||||
dict(help='start/stop debugging server PHP 7.3 configuration',
|
||||
action='store' or 'store_const',
|
||||
choices=('on', 'off'), const='on', nargs='?')),
|
||||
(['--fpm73'],
|
||||
dict(help='start/stop debugging fastcgi 7.3 configuration',
|
||||
dict(help='start/stop debugging OpenLiteSpeed server '
|
||||
'configuration',
|
||||
action='store' or 'store_const',
|
||||
choices=('on', 'off'), const='on', nargs='?')),
|
||||
(['--mysql'],
|
||||
@@ -65,10 +46,6 @@ class WODebugController(CementBaseController):
|
||||
dict(help='start/stop wordpress debugging for site',
|
||||
action='store' or 'store_const', choices=('on', 'off'),
|
||||
const='on', nargs='?')),
|
||||
(['--rewrite'],
|
||||
dict(help='start/stop debugging nginx rewrite rules for site',
|
||||
action='store' or 'store_const', choices=('on', 'off'),
|
||||
const='on', nargs='?')),
|
||||
(['--all'],
|
||||
dict(help='start/stop debugging all server parameters',
|
||||
action='store' or 'store_const', choices=('on', 'off'),
|
||||
@@ -84,325 +61,80 @@ class WODebugController(CementBaseController):
|
||||
usage = "wo debug [<site_name>] [options] "
|
||||
|
||||
@expose(hide=True)
|
||||
def debug_nginx(self):
|
||||
"""Start/Stop Nginx debug"""
|
||||
def debug_ols(self):
|
||||
"""Start/Stop OpenLiteSpeed debug"""
|
||||
ols_conf = "{0}/httpd_config.conf".format(WOVar.wo_ols_conf_dir)
|
||||
|
||||
# start global debug
|
||||
if (self.app.pargs.nginx == 'on' and not self.app.pargs.site_name):
|
||||
try:
|
||||
debug_address = (self.app.config.get('stack', 'ip-address')
|
||||
.split())
|
||||
except Exception as e:
|
||||
Log.debug(self, "{0}".format(e))
|
||||
debug_address = ['0.0.0.0/0']
|
||||
if not WOFileUtils.grepcheck(self, ols_conf, 'logLevel DEBUG'):
|
||||
Log.info(self, "Setting up OpenLiteSpeed debug log level")
|
||||
WOFileUtils.searchreplace(
|
||||
self, ols_conf,
|
||||
'logLevel NOTICE', 'logLevel DEBUG')
|
||||
self.trigger_ols = True
|
||||
else:
|
||||
Log.info(self, "OpenLiteSpeed debug already enabled")
|
||||
|
||||
# Check if IP address is 127.0.0.1 then enable debug globally
|
||||
if debug_address == ['127.0.0.1'] or debug_address == []:
|
||||
debug_address = ['0.0.0.0/0']
|
||||
|
||||
for ip_addr in debug_address:
|
||||
if not ("debug_connection "+ip_addr in open('/etc/nginx/'
|
||||
'nginx.conf',
|
||||
encoding='utf-8').read()):
|
||||
Log.info(self, "Setting up Nginx debug connection"
|
||||
" for "+ip_addr)
|
||||
WOShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ "
|
||||
"\\ $(echo debug_connection "
|
||||
"{ip}\;)\" /etc/nginx/"
|
||||
"nginx.conf".format(ip=ip_addr))
|
||||
self.trigger_nginx = True
|
||||
|
||||
if not self.trigger_nginx:
|
||||
Log.info(self, "Nginx debug connection already enabled")
|
||||
|
||||
self.msg = self.msg + ["/var/log/nginx/*.error.log"]
|
||||
self.msg = self.msg + [
|
||||
'/usr/local/lsws/logs/error.log']
|
||||
|
||||
# stop global debug
|
||||
elif (self.app.pargs.nginx == 'off' and not self.app.pargs.site_name):
|
||||
if "debug_connection " in open('/etc/nginx/nginx.conf',
|
||||
encoding='utf-8').read():
|
||||
Log.info(self, "Disabling Nginx debug connections")
|
||||
WOShellExec.cmd_exec(self, "sed -i \"/debug_connection.*/d\""
|
||||
" /etc/nginx/nginx.conf")
|
||||
self.trigger_nginx = True
|
||||
elif (self.app.pargs.nginx == 'off' and
|
||||
not self.app.pargs.site_name):
|
||||
if WOFileUtils.grepcheck(self, ols_conf, 'logLevel DEBUG'):
|
||||
Log.info(self, "Disabling OpenLiteSpeed debug log level")
|
||||
WOFileUtils.searchreplace(
|
||||
self, ols_conf,
|
||||
'logLevel DEBUG', 'logLevel NOTICE')
|
||||
self.trigger_ols = True
|
||||
else:
|
||||
Log.info(self, "Nginx debug connection already disabled")
|
||||
Log.info(self, "OpenLiteSpeed debug already disabled")
|
||||
|
||||
# start site specific debug
|
||||
# start site-specific debug
|
||||
elif (self.app.pargs.nginx == 'on' and self.app.pargs.site_name):
|
||||
config_path = ("/etc/nginx/sites-available/{0}"
|
||||
.format(self.app.pargs.site_name))
|
||||
if os.path.isfile(config_path):
|
||||
if not WOShellExec.cmd_exec(self, "grep \"error.log debug\" "
|
||||
"{0}".format(config_path)):
|
||||
Log.info(self, "Starting NGINX debug connection for "
|
||||
vhconf = "{0}/{1}/vhconf.conf".format(
|
||||
WOVar.wo_ols_vhost_dir, self.app.pargs.site_name)
|
||||
if os.path.isfile(vhconf):
|
||||
if not WOFileUtils.grepcheck(
|
||||
self, vhconf, 'logLevel DEBUG'):
|
||||
Log.info(self, "Starting OpenLiteSpeed debug for "
|
||||
"{0}".format(self.app.pargs.site_name))
|
||||
WOShellExec.cmd_exec(self, "sed -i \"s/error.log;/"
|
||||
"error.log "
|
||||
"debug;/\" {0}".format(config_path))
|
||||
self.trigger_nginx = True
|
||||
|
||||
WOFileUtils.searchreplace(
|
||||
self, vhconf,
|
||||
'logLevel NOTICE', 'logLevel DEBUG')
|
||||
self.trigger_ols = True
|
||||
else:
|
||||
Log.info(self, "Nginx debug for site already enabled")
|
||||
Log.info(self, "OpenLiteSpeed debug for site "
|
||||
"already enabled")
|
||||
|
||||
self.msg = self.msg + ['{0}{1}/logs/error.log'
|
||||
.format(WOVar.wo_webroot,
|
||||
self.app.pargs.site_name)]
|
||||
|
||||
else:
|
||||
Log.info(self, "{0} domain not valid"
|
||||
.format(self.app.pargs.site_name))
|
||||
|
||||
# stop site specific debug
|
||||
# stop site-specific debug
|
||||
elif (self.app.pargs.nginx == 'off' and self.app.pargs.site_name):
|
||||
config_path = ("/etc/nginx/sites-available/{0}"
|
||||
.format(self.app.pargs.site_name))
|
||||
if os.path.isfile(config_path):
|
||||
if WOShellExec.cmd_exec(self, "grep \"error.log debug\" {0}"
|
||||
.format(config_path)):
|
||||
Log.info(self, "Stoping NGINX debug connection for {0}"
|
||||
.format(self.app.pargs.site_name))
|
||||
WOShellExec.cmd_exec(self, "sed -i \"s/error.log debug;/"
|
||||
"error.log;/\" {0}"
|
||||
.format(config_path))
|
||||
self.trigger_nginx = True
|
||||
|
||||
vhconf = "{0}/{1}/vhconf.conf".format(
|
||||
WOVar.wo_ols_vhost_dir, self.app.pargs.site_name)
|
||||
if os.path.isfile(vhconf):
|
||||
if WOFileUtils.grepcheck(
|
||||
self, vhconf, 'logLevel DEBUG'):
|
||||
Log.info(self, "Stopping OpenLiteSpeed debug for "
|
||||
"{0}".format(self.app.pargs.site_name))
|
||||
WOFileUtils.searchreplace(
|
||||
self, vhconf,
|
||||
'logLevel DEBUG', 'logLevel NOTICE')
|
||||
self.trigger_ols = True
|
||||
else:
|
||||
|
||||
Log.info(self, "Nginx debug for site already disabled")
|
||||
Log.info(self, "OpenLiteSpeed debug for site "
|
||||
"already disabled")
|
||||
else:
|
||||
Log.info(self, "{0} domain not valid"
|
||||
.format(self.app.pargs.site_name))
|
||||
|
||||
@expose(hide=True)
|
||||
def debug_php(self):
|
||||
"""Start/Stop PHP debug"""
|
||||
# PHP global debug start
|
||||
|
||||
if (self.app.pargs.php == 'on' and not self.app.pargs.site_name):
|
||||
if not (WOShellExec.cmd_exec(self, "sed -n \"/upstream php"
|
||||
"{/,/}/p \" /etc/nginx/"
|
||||
"conf.d/upstream.conf "
|
||||
"| grep 9001")):
|
||||
|
||||
Log.info(self, "Enabling PHP debug")
|
||||
|
||||
# Change upstream.conf
|
||||
nc = NginxConfig()
|
||||
nc.loadf('/etc/nginx/conf.d/upstream.conf')
|
||||
nc.set([('upstream', 'php',), 'server'], '127.0.0.1:9001')
|
||||
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
||||
|
||||
# Enable xdebug
|
||||
WOFileUtils.searchreplace(self, "/etc/{0}/"
|
||||
"mods-available/".format("php/7.2") +
|
||||
"xdebug.ini",
|
||||
";zend_extension",
|
||||
"zend_extension")
|
||||
|
||||
# Fix slow log is not enabled default in PHP5.6
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2"))
|
||||
config['debug']['slowlog'] = '/var/log/{0}/slow.log'.format(
|
||||
"php/7.2")
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2"),
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "Writting debug.conf configuration into "
|
||||
"/etc/{0}/fpm/pool.d/debug.conf".format("php/7.2"))
|
||||
config.write(confifile)
|
||||
|
||||
self.trigger_php = True
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "PHP debug is already enabled")
|
||||
|
||||
self.msg = self.msg + ['/var/log/{0}/slow.log'.format("php/7.2")]
|
||||
|
||||
# PHP global debug stop
|
||||
elif (self.app.pargs.php == 'off' and not self.app.pargs.site_name):
|
||||
if WOShellExec.cmd_exec(self, " sed -n \"/upstream php {/,/}/p\" "
|
||||
"/etc/nginx/conf.d/upstream.conf "
|
||||
"| grep 9001"):
|
||||
Log.info(self, "Disabling PHP debug")
|
||||
|
||||
# Change upstream.conf
|
||||
nc = NginxConfig()
|
||||
nc.loadf('/etc/nginx/conf.d/upstream.conf')
|
||||
nc.set([('upstream', 'php',), 'server'], '127.0.0.1:9000')
|
||||
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
||||
|
||||
# Disable xdebug
|
||||
WOFileUtils.searchreplace(self, "/etc/{0}/"
|
||||
"mods-available/".format("php/7.2") +
|
||||
"xdebug.ini",
|
||||
"zend_extension",
|
||||
";zend_extension")
|
||||
|
||||
self.trigger_php = True
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "PHP debug is already disabled")
|
||||
|
||||
@expose(hide=True)
|
||||
def debug_fpm(self):
|
||||
"""Start/Stop PHP5-FPM debug"""
|
||||
# PHP5-FPM start global debug
|
||||
if (self.app.pargs.fpm == 'on' and not self.app.pargs.site_name):
|
||||
if not WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
||||
"/etc/{0}/"
|
||||
"fpm/php-fpm.conf".format("php/7.2")):
|
||||
Log.info(self, "Setting up PHP5-FPM log_level = debug")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"))
|
||||
config.remove_option('global', 'include')
|
||||
config['global']['log_level'] = 'debug'
|
||||
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format(
|
||||
"php/7.2")
|
||||
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"),
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writting php5-FPM configuration into "
|
||||
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2"))
|
||||
config.write(configfile)
|
||||
self.trigger_php = True
|
||||
else:
|
||||
Log.info(self, "PHP5-FPM log_level = debug already setup")
|
||||
|
||||
self.msg = self.msg + ['/var/log/{0}/fpm.log'.format("php/7.2")]
|
||||
|
||||
# PHP5-FPM stop global debug
|
||||
elif (self.app.pargs.fpm == 'off' and not self.app.pargs.site_name):
|
||||
if WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
||||
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2")):
|
||||
Log.info(self, "Disabling PHP5-FPM log_level = debug")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"))
|
||||
config.remove_option('global', 'include')
|
||||
config['global']['log_level'] = 'notice'
|
||||
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format(
|
||||
"php/7.2")
|
||||
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"),
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "writting php5 configuration into "
|
||||
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2"))
|
||||
config.write(configfile)
|
||||
|
||||
self.trigger_php = True
|
||||
else:
|
||||
Log.info(self, "PHP5-FPM log_level = debug already disabled")
|
||||
|
||||
@expose(hide=True)
|
||||
def debug_php73(self):
|
||||
"""Start/Stop PHP debug"""
|
||||
# PHP global debug start
|
||||
|
||||
if (self.app.pargs.php73 == 'on' and not self.app.pargs.site_name):
|
||||
if not (WOShellExec.cmd_exec(self, "sed -n \"/upstream php73"
|
||||
"{/,/}/p \" /etc/nginx/"
|
||||
"conf.d/upstream.conf "
|
||||
"| grep 9173")):
|
||||
|
||||
Log.info(self, "Enabling PHP 7.3 debug")
|
||||
|
||||
# Change upstream.conf
|
||||
nc = NginxConfig()
|
||||
nc.loadf('/etc/nginx/conf.d/upstream.conf')
|
||||
nc.set([('upstream', 'php73',), 'server'], '127.0.0.1:9173')
|
||||
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
||||
|
||||
# Enable xdebug
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.3/mods-available/"
|
||||
"xdebug.ini",
|
||||
";zend_extension",
|
||||
"zend_extension")
|
||||
|
||||
# Fix slow log is not enabled default in PHP5.6
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.3/fpm/pool.d/debug.conf')
|
||||
config['debug']['slowlog'] = '/var/log/php/7.3/slow.log'
|
||||
config['debug']['request_slowlog_timeout'] = '10s'
|
||||
with open('/etc/php/7.3/fpm/pool.d/debug.conf',
|
||||
encoding='utf-8', mode='w') as confifile:
|
||||
Log.debug(self, "Writting debug.conf configuration into "
|
||||
"/etc/php/7.3/fpm/pool.d/debug.conf")
|
||||
config.write(confifile)
|
||||
|
||||
self.trigger_php = True
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "PHP debug is already enabled")
|
||||
|
||||
self.msg = self.msg + ['/var/log/php/7.3/slow.log']
|
||||
|
||||
# PHP global debug stop
|
||||
elif (self.app.pargs.php73 == 'off' and not self.app.pargs.site_name):
|
||||
if WOShellExec.cmd_exec(self, " sed -n \"/upstream "
|
||||
"php73 {/,/}/p\" "
|
||||
"/etc/nginx/conf.d/upstream.conf "
|
||||
"| grep 9173"):
|
||||
Log.info(self, "Disabling PHP 7.3 debug")
|
||||
|
||||
# Change upstream.conf
|
||||
nc = NginxConfig()
|
||||
nc.loadf('/etc/nginx/conf.d/upstream.conf')
|
||||
nc.set([('upstream', 'php73',), 'server'],
|
||||
'unix:/var/run/php/php73-fpm.sock')
|
||||
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
||||
|
||||
# Disable xdebug
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.3/mods-available/"
|
||||
"xdebug.ini",
|
||||
"zend_extension",
|
||||
";zend_extension")
|
||||
|
||||
self.trigger_php = True
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "PHP 7.3 debug is already disabled")
|
||||
|
||||
@expose(hide=True)
|
||||
def debug_fpm73(self):
|
||||
"""Start/Stop PHP5-FPM debug"""
|
||||
# PHP5-FPM start global debug
|
||||
if (self.app.pargs.fpm73 == 'on' and not self.app.pargs.site_name):
|
||||
if not WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
||||
"/etc/php/7.3/fpm/php-fpm.conf"):
|
||||
Log.info(self, "Setting up PHP7.3-FPM log_level = debug")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.3/fpm/php-fpm.conf')
|
||||
config.remove_option('global', 'include')
|
||||
config['global']['log_level'] = 'debug'
|
||||
config['global']['include'] = '/etc/php/7.3/fpm/pool.d/*.conf'
|
||||
with open('/etc/php/7.3/fpm/php-fpm.conf',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writing the PHP configuration into "
|
||||
"/etc/php/7.3/fpm/php-fpm.conf")
|
||||
config.write(configfile)
|
||||
self.trigger_php = True
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM log_level = debug already setup")
|
||||
|
||||
self.msg = self.msg + ['/var/log/php/7.3/fpm.log']
|
||||
|
||||
# PHP5-FPM stop global debug
|
||||
elif (self.app.pargs.fpm73 == 'off' and not self.app.pargs.site_name):
|
||||
if WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
||||
"/etc/php/7.3/fpm/php-fpm.conf"):
|
||||
Log.info(self, "Disabling PHP7.3-FPM log_level = debug")
|
||||
config = configparser.ConfigParser()
|
||||
config.read('/etc/php/7.3/fpm/php-fpm.conf')
|
||||
config.remove_option('global', 'include')
|
||||
config['global']['log_level'] = 'notice'
|
||||
config['global']['include'] = '/etc/php/7.3/fpm/pool.d/*.conf'
|
||||
with open('/etc/php/7.3/fpm/php-fpm.conf',
|
||||
encoding='utf-8', mode='w') as configfile:
|
||||
Log.debug(self, "Writing the php7.3 configuration into "
|
||||
"/etc/php/7.3/fpm/php-fpm.conf")
|
||||
config.write(configfile)
|
||||
self.trigger_php = True
|
||||
else:
|
||||
Log.info(self, "PHP7.3-FPM log_level "
|
||||
"= debug already disabled")
|
||||
|
||||
@expose(hide=True)
|
||||
def debug_mysql(self):
|
||||
"""Start/Stop MySQL debug"""
|
||||
@@ -520,91 +252,13 @@ class WODebugController(CementBaseController):
|
||||
else:
|
||||
Log.error(self, "Missing argument site name")
|
||||
|
||||
@expose(hide=True)
|
||||
def debug_rewrite(self):
|
||||
"""Start/Stop Nginx rewrite rules debug"""
|
||||
# Start Nginx rewrite debug globally
|
||||
if (self.app.pargs.rewrite == 'on' and not self.app.pargs.site_name):
|
||||
if not WOShellExec.cmd_exec(self, "grep \"rewrite_log on;\" "
|
||||
"/etc/nginx/nginx.conf"):
|
||||
Log.info(self, "Setting up Nginx rewrite logs")
|
||||
WOShellExec.cmd_exec(self, "sed -i \'/http {/a \\\\t"
|
||||
"rewrite_log on;\' /etc/nginx/nginx.conf")
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "Nginx rewrite logs already enabled")
|
||||
|
||||
if '/var/log/nginx/*.error.log' not in self.msg:
|
||||
self.msg = self.msg + ['/var/log/nginx/*.error.log']
|
||||
|
||||
# Stop Nginx rewrite debug globally
|
||||
elif (self.app.pargs.rewrite == 'off' and
|
||||
not self.app.pargs.site_name):
|
||||
if WOShellExec.cmd_exec(self, "grep \"rewrite_log on;\" "
|
||||
"/etc/nginx/nginx.conf"):
|
||||
Log.info(self, "Disabling Nginx rewrite logs")
|
||||
WOShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\""
|
||||
" /etc/nginx/nginx.conf")
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "Nginx rewrite logs already disabled")
|
||||
# Start Nginx rewrite for site
|
||||
elif (self.app.pargs.rewrite == 'on' and self.app.pargs.site_name):
|
||||
config_path = ("/etc/nginx/sites-available/{0}"
|
||||
.format(self.app.pargs.site_name))
|
||||
if not WOShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}"
|
||||
.format(config_path)):
|
||||
Log.info(self, "Setting up Nginx rewrite logs for {0}"
|
||||
.format(self.app.pargs.site_name))
|
||||
WOShellExec.cmd_exec(self, "sed -i \"/access_log/i \\\\\\t"
|
||||
"rewrite_log on;\" {0}"
|
||||
.format(config_path))
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "Nginx rewrite logs for {0} already setup"
|
||||
.format(self.app.pargs.site_name))
|
||||
|
||||
if ('{0}{1}/logs/error.log'.format(WOVar.wo_webroot,
|
||||
self.app.pargs.site_name)
|
||||
not in self.msg):
|
||||
self.msg = self.msg + ['{0}{1}/logs/error.log'
|
||||
.format(WOVar.wo_webroot,
|
||||
self.app.pargs.site_name)]
|
||||
|
||||
# Stop Nginx rewrite for site
|
||||
elif (self.app.pargs.rewrite == 'off' and self.app.pargs.site_name):
|
||||
config_path = ("/etc/nginx/sites-available/{0}"
|
||||
.format(self.app.pargs.site_name))
|
||||
if WOShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}"
|
||||
.format(config_path)):
|
||||
Log.info(self, "Disabling Nginx rewrite logs for {0}"
|
||||
.format(self.app.pargs.site_name))
|
||||
WOShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\" {0}"
|
||||
.format(config_path))
|
||||
self.trigger_nginx = True
|
||||
else:
|
||||
Log.info(self, "Nginx rewrite logs for {0} already "
|
||||
" disabled".format(self.app.pargs.site_name))
|
||||
|
||||
@expose(hide=True)
|
||||
def signal_handler(self, app, signal, frame):
|
||||
"""Handle Ctrl+c hevent for -i option of debug"""
|
||||
"""Handle Ctrl+c event for -i option of debug"""
|
||||
self.start = False
|
||||
if self.app.pargs.nginx:
|
||||
self.app.pargs.nginx = 'off'
|
||||
self.debug_nginx()
|
||||
if self.app.pargs.php:
|
||||
self.app.pargs.php = 'off'
|
||||
self.debug_php()
|
||||
if self.app.pargs.php73:
|
||||
self.app.pargs.php73 = 'off'
|
||||
self.debug_php73()
|
||||
if self.app.pargs.fpm:
|
||||
self.app.pargs.fpm = 'off'
|
||||
self.debug_fpm()
|
||||
if self.app.pargs.fpm73:
|
||||
self.app.pargs.fpm73 = 'off'
|
||||
self.debug_fpm73()
|
||||
self.debug_ols()
|
||||
if self.app.pargs.mysql:
|
||||
# MySQL debug will not work for remote MySQL
|
||||
if WOVar.wo_mysql_host == "localhost":
|
||||
@@ -616,20 +270,11 @@ class WODebugController(CementBaseController):
|
||||
if self.app.pargs.wp:
|
||||
self.app.pargs.wp = 'off'
|
||||
self.debug_wp()
|
||||
if self.app.pargs.rewrite:
|
||||
self.app.pargs.rewrite = 'off'
|
||||
self.debug_rewrite()
|
||||
|
||||
# Reload Nginx
|
||||
if self.trigger_nginx:
|
||||
WOService.reload_service(self, 'nginx')
|
||||
# Reload OpenLiteSpeed
|
||||
if self.trigger_ols:
|
||||
WOService.reload_service(self, 'lsws')
|
||||
|
||||
# Reload PHP
|
||||
if self.trigger_php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
WOService.reload_service(self, 'php7.2-fpm')
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
WOService.reload_service(self, 'php7.3-fpm')
|
||||
self.app.close(0)
|
||||
|
||||
@expose(hide=True)
|
||||
@@ -638,13 +283,10 @@ class WODebugController(CementBaseController):
|
||||
# self.start = True
|
||||
self.interactive = False
|
||||
self.msg = []
|
||||
self.trigger_nginx = False
|
||||
self.trigger_php = False
|
||||
self.trigger_ols = False
|
||||
|
||||
if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and
|
||||
(not self.app.pargs.php73) and (not self.app.pargs.fpm) and
|
||||
(not self.app.pargs.fpm73) and (not self.app.pargs.mysql) and
|
||||
(not self.app.pargs.wp) and (not self.app.pargs.rewrite) and
|
||||
if ((not self.app.pargs.nginx) and (not self.app.pargs.mysql) and
|
||||
(not self.app.pargs.wp) 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)):
|
||||
@@ -712,46 +354,21 @@ class WODebugController(CementBaseController):
|
||||
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 WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
self.app.pargs.php73 = 'on'
|
||||
self.app.pargs.fpm73 = '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 WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
self.app.pargs.php73 = 'off'
|
||||
self.app.pargs.fpm73 = '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.php73) and (not self.app.pargs.fpm) and
|
||||
(not self.app.pargs.fpm73) and (not self.app.pargs.mysql) and
|
||||
(not self.app.pargs.wp) and (not self.app.pargs.rewrite) and
|
||||
if ((not self.app.pargs.nginx) and (not self.app.pargs.mysql) and
|
||||
(not self.app.pargs.wp) 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.php73:
|
||||
self.debug_php73()
|
||||
if self.app.pargs.fpm73:
|
||||
self.debug_fpm73()
|
||||
self.debug_ols()
|
||||
if self.app.pargs.mysql:
|
||||
# MySQL debug will not work for remote MySQL
|
||||
if WOVar.wo_mysql_host == "localhost":
|
||||
@@ -761,21 +378,13 @@ class WODebugController(CementBaseController):
|
||||
"debugging remote servers")
|
||||
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:
|
||||
WOService.reload_service(self, 'nginx')
|
||||
# Reload PHP
|
||||
if self.trigger_php:
|
||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||
WOService.restart_service(self, 'php7.2-fpm')
|
||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||
WOService.restart_service(self, 'php7.3-fpm')
|
||||
# Reload OpenLiteSpeed
|
||||
if self.trigger_ols:
|
||||
WOService.reload_service(self, 'lsws')
|
||||
|
||||
if len(self.msg) > 0:
|
||||
if not self.app.pargs.interactive:
|
||||
|
||||
Reference in New Issue
Block a user