From bc3e2329111c143688cc36cbab60f21da05124e8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 1 Apr 2015 12:29:15 +0530 Subject: [PATCH] Improved Pagespeed configuration config --- ee/cli/plugins/site.py | 25 ++++--------------------- ee/cli/plugins/site_functions.py | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index d0cd4ba2..399198c4 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -486,27 +486,6 @@ class EESiteCreateController(CementBaseController): hhvm = False if data and self.app.pargs.pagespeed: - if (os.path.isdir('/etc/nginx') and - (not os.path.isfile('/etc/nginx/conf.d/pagespeed.conf'))): - # Pagespeed configuration - Log.debug(self, 'Writting the Pagespeed Global ' - 'configuration to file /etc/nginx/conf.d/' - 'pagespeed.conf') - ee_nginx = open('/etc/nginx/conf.d/pagespeed.conf', - encoding='utf-8', mode='w') - self.app.render((data), 'pagespeed-global.mustache', - out=ee_nginx) - ee_nginx.close() - - Log.debug(self, 'Writting the Pagespeed common ' - 'configuration to file /etc/nginx/common/' - 'pagespeed.conf') - ee_nginx = open('/etc/nginx/common/pagespeed.conf', - encoding='utf-8', mode='w') - self.app.render((data), 'pagespeed-common.mustache', - out=ee_nginx) - ee_nginx.close() - data['pagespeed'] = True pagespeed = True elif data: @@ -1005,13 +984,17 @@ class EESiteUpdateController(CementBaseController): if self.app.pargs.hhvm == 'on': data['hhvm'] = True + hhvm = True elif self.app.pargs.hhvm == 'off': data['hhvm'] = False + hhvm = False if self.app.pargs.pagespeed == 'on': data['pagespeed'] = True + pagespeed = True elif self.app.pargs.pagespeed == 'off': data['pagespeed'] = False + pagespeed = False if not data: Log.error(self, " Cannot update {0}, Invalid Options" diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 440e1845..b8c908d6 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -467,6 +467,30 @@ def site_package_check(self, stype): if not EEAptGet.is_installed(self, 'hhvm'): apt_packages = apt_packages + EEVariables.ee_hhvm + # Check if Nginx is allready installed and Pagespeed config there or not + # If not then copy pagespeed config + if data and self.app.pargs.pagespeed: + if (os.path.isdir('/etc/nginx') and + (not os.path.isfile('/etc/nginx/conf.d/pagespeed.conf'))): + # Pagespeed configuration + Log.debug(self, 'Writting the Pagespeed Global ' + 'configuration to file /etc/nginx/conf.d/' + 'pagespeed.conf') + ee_nginx = open('/etc/nginx/conf.d/pagespeed.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'pagespeed-global.mustache', + out=ee_nginx) + ee_nginx.close() + + Log.debug(self, 'Writting the Pagespeed common ' + 'configuration to file /etc/nginx/common/' + 'pagespeed.conf') + ee_nginx = open('/etc/nginx/common/pagespeed.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'pagespeed-common.mustache', + out=ee_nginx) + ee_nginx.close() + return(stack.install(apt_packages=apt_packages, packages=packages, disp_msg=False))