Improve purge opcache

This commit is contained in:
VirtuBox
2023-08-05 17:31:40 +02:00
parent c4a6356cff
commit 9f5dacb4ec

View File

@@ -9,6 +9,7 @@ from wo.core.aptget import WOAptGet
from wo.core.logging import Log from wo.core.logging import Log
from wo.core.services import WOService from wo.core.services import WOService
from wo.core.shellexec import WOShellExec from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar
def wo_clean_hook(app): def wo_clean_hook(app):
@@ -54,7 +55,7 @@ class WOCleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_redis(self): def clean_redis(self):
"""This function clears Redis cache""" """This function clears Redis cache"""
if(WOAptGet.is_installed(self, "redis-server")): if (WOAptGet.is_installed(self, "redis-server")):
Log.info(self, "Cleaning Redis cache") Log.info(self, "Cleaning Redis cache")
WOShellExec.cmd_exec(self, "redis-cli flushall") WOShellExec.cmd_exec(self, "redis-cli flushall")
else: else:
@@ -62,7 +63,7 @@ class WOCleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_fastcgi(self): def clean_fastcgi(self):
if(os.path.isdir("/var/run/nginx-cache") and if (os.path.isdir("/var/run/nginx-cache") and
os.path.exists('/usr/sbin/nginx')): os.path.exists('/usr/sbin/nginx')):
Log.info(self, "Cleaning NGINX FastCGI cache") Log.info(self, "Cleaning NGINX FastCGI cache")
WOShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") WOShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*")
@@ -78,15 +79,12 @@ class WOCleanController(CementBaseController):
'/var/www/22222/htdocs/cache/opcache')): '/var/www/22222/htdocs/cache/opcache')):
try: try:
Log.info(self, "Cleaning opcache") Log.info(self, "Cleaning opcache")
if os.path.exists('{0}php72.php'.format(opcache_dir)): wo_php_version = list(WOVar.wo_php_versions.keys())
requests.get( for wo_php in wo_php_version:
"http://127.0.0.1/cache/opcache/php72.php") if os.path.exists('{0}{1}.php'.format(opcache_dir, wo_php)):
if os.path.exists('{0}php73.php'.format(opcache_dir)): requests.get(
requests.get( "http://127.0.0.1/cache/opcache/{0}.php".format(wo_php))
"http://127.0.0.1/cache/opcache/php73.php")
if os.path.exists('{0}php74.php'.format(opcache_dir)):
requests.get(
"http://127.0.0.1/cache/opcache/php74.php")
except requests.HTTPError as e: except requests.HTTPError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.debug(self, "Unable hit url, " Log.debug(self, "Unable hit url, "