From ef6c1d2a9901adad62ee665f746c5a1856e9b719 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Tue, 10 Dec 2019 18:42:27 +0100 Subject: [PATCH] Improve opcache clean * force enabling php imagick extension --- CHANGELOG.md | 4 +++- wo/cli/plugins/clean.py | 18 ++++++++++++------ wo/cli/plugins/stack_pref.py | 13 ++++++++++++- wo/cli/templates/stub_status.mustache | 12 +++++++++--- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b18e3c0..bcb914e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), #### Changed -- Improve WordOps performance by removing useless imports in `wo site` code +- Improved WordOps performance by removing useless imports in `wo site` code +- Improved opcache cleaning with `wo clean --opcache` +- Force php imagick extension to be enabled after php-fpm install #### Fixed diff --git a/wo/cli/plugins/clean.py b/wo/cli/plugins/clean.py index fd3917e..e4a05e3 100644 --- a/wo/cli/plugins/clean.py +++ b/wo/cli/plugins/clean.py @@ -72,16 +72,22 @@ class WOCleanController(CementBaseController): @expose(hide=True) def clean_opcache(self): + opcache_dir = '/var/www/22222/htdocs/cache/opcache/' if (os.path.exists('/usr/sbin/nginx') and os.path.exists( - '/var/www/22222/htdocs/cache/opcache/php72.php')): + '/var/www/22222/htdocs/cache/opcache')): try: Log.info(self, "Cleaning opcache") - opgui = requests.get( - "http://127.0.0.1/cache/opcache/php72.php") - if opgui.status_code != '200' or opgui.status_code != '302': - Log.warn(self, 'Cleaning opcache failed') - except Exception as e: + 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") + except requests.HTTPError as e: Log.debug(self, "{0}".format(e)) Log.debug(self, "Unable hit url, " " http://127.0.0.1/cache/opcache/" diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index 6af61d1..eb41c4e 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -459,7 +459,7 @@ def post_pref(self, apt_packages, packages, upgrade=False): WOShellExec.cmd_exec(self, 'systemctl daemon-reload') WOService.restart_service(self, 'nginx') - if set(WOVar.wo_php72).issubset(set(apt_packages)): + if 'php7.2-fpm' in apt_packages: WOGit.add(self, ["/etc/php"], msg="Adding PHP into Git") Log.info(self, "Configuring php7.2-fpm") ngxroot = '/var/www/' @@ -600,6 +600,9 @@ def post_pref(self, apt_packages, packages, upgrade=False): 'www-data', 'www-data', recursive=True) + # enable imagick php extension + WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick') + # check service restart or rollback configuration if not WOService.restart_service(self, 'php7.2-fpm'): WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") @@ -746,6 +749,10 @@ def post_pref(self, apt_packages, packages, upgrade=False): .format(ngxroot), 'www-data', 'www-data', recursive=True) + + # enable imagick php extension + WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick') + # check service restart or rollback configuration if not WOService.restart_service(self, 'php7.3-fpm'): WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") @@ -892,6 +899,10 @@ def post_pref(self, apt_packages, packages, upgrade=False): .format(ngxroot), 'www-data', 'www-data', recursive=True) + + # enable imagick php extension + WOShellExec.cmd_exec(self, 'phpenmod -v ALL imagick') + # check service restart or rollback configuration if not WOService.restart_service(self, 'php7.4-fpm'): WOGit.rollback(self, ["/etc/php"], msg="Rollback PHP") diff --git a/wo/cli/templates/stub_status.mustache b/wo/cli/templates/stub_status.mustache index ccbc255..8979508 100644 --- a/wo/cli/templates/stub_status.mustache +++ b/wo/cli/templates/stub_status.mustache @@ -4,6 +4,12 @@ upstream phpstatus { server unix:/run/php/php72-fpm.sock; } +upstream php73opcache { + server unix:/run/php/php73-fpm.sock; +} +upstream php74opcache { + server unix:/run/php/php74-fpm.sock; +} {{/phpconf}} server { listen 127.0.0.1:80; @@ -33,21 +39,21 @@ server { location /cache/opcache/php72.php { try_files $uri =404; include fastcgi_params; - fastcgi_pass php72; + fastcgi_pass phpstatus; access_log off; log_not_found off; } location /cache/opcache/php73.php { try_files $uri =404; include fastcgi_params; - fastcgi_pass php73; + fastcgi_pass php73opcache; access_log off; log_not_found off; } location /cache/opcache/php74.php { try_files $uri =404; include fastcgi_params; - fastcgi_pass php74; + fastcgi_pass php74opcache; access_log off; log_not_found off; }