From 9f5dacb4ec061b876b8276138280b4e5e2790b04 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sat, 5 Aug 2023 17:31:40 +0200 Subject: [PATCH] Improve purge opcache --- wo/cli/plugins/clean.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/wo/cli/plugins/clean.py b/wo/cli/plugins/clean.py index e4a05e3..1dbd763 100644 --- a/wo/cli/plugins/clean.py +++ b/wo/cli/plugins/clean.py @@ -9,6 +9,7 @@ from wo.core.aptget import WOAptGet from wo.core.logging import Log from wo.core.services import WOService from wo.core.shellexec import WOShellExec +from wo.core.variables import WOVar def wo_clean_hook(app): @@ -54,7 +55,7 @@ class WOCleanController(CementBaseController): @expose(hide=True) def clean_redis(self): """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") WOShellExec.cmd_exec(self, "redis-cli flushall") else: @@ -62,7 +63,7 @@ class WOCleanController(CementBaseController): @expose(hide=True) 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')): Log.info(self, "Cleaning NGINX FastCGI cache") WOShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") @@ -78,15 +79,12 @@ class WOCleanController(CementBaseController): '/var/www/22222/htdocs/cache/opcache')): try: Log.info(self, "Cleaning opcache") - if os.path.exists('{0}php72.php'.format(opcache_dir)): - requests.get( - "http://127.0.0.1/cache/opcache/php72.php") - if os.path.exists('{0}php73.php'.format(opcache_dir)): - requests.get( - "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") + wo_php_version = list(WOVar.wo_php_versions.keys()) + for wo_php in wo_php_version: + if os.path.exists('{0}{1}.php'.format(opcache_dir, wo_php)): + requests.get( + "http://127.0.0.1/cache/opcache/{0}.php".format(wo_php)) + except requests.HTTPError as e: Log.debug(self, "{0}".format(e)) Log.debug(self, "Unable hit url, "