From ac8e38776f0672e77f06ebd4853ec8e47261525e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 11 May 2015 15:26:07 +0530 Subject: [PATCH 01/14] Fix nginx config writing for debian --- ee/cli/plugins/stack.py | 7 ++++++- ee/cli/templates/nginx-core.mustache | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index cd0d624f..272385c3 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -218,7 +218,12 @@ class EEStackController(CementBaseController): nc.savef('/etc/nginx/nginx.conf') # Custom Nginx configuration by EasyEngine - data = dict(version=EEVariables.ee_version) + if EEVariables.ee_platform_distro == 'Ubuntu': + data = dict(version=EEVariables.ee_version, + Ubuntu=True) + else: + data = dict(version=EEVariables.ee_version, + Debian=True) Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/conf.d/ee-nginx.conf ') ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', diff --git a/ee/cli/templates/nginx-core.mustache b/ee/cli/templates/nginx-core.mustache index c1cd7d60..bdce6d2d 100644 --- a/ee/cli/templates/nginx-core.mustache +++ b/ee/cli/templates/nginx-core.mustache @@ -21,7 +21,9 @@ client_max_body_size 100m; # SSL Settings ssl_session_cache shared:SSL:20m; ssl_session_timeout 10m; +{{#Ubuntu}} ssl_prefer_server_ciphers on; +{{/Ubuntu}} ssl_ciphers HIGH:!aNULL:!MD5:!kEDH; # Log format Settings From a4a202459d3370f4053fc460b16181fb4ca0789b Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 11 May 2015 15:58:09 +0530 Subject: [PATCH 02/14] bypass php repo add for jessie --- ee/cli/plugins/stack.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 272385c3..7e9d652e 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -160,11 +160,13 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_php).issubset(set(apt_packages)): Log.info(self, "Adding repository for PHP, please wait...") + # Add repository for php if EEVariables.ee_platform_distro == 'debian': - Log.debug(self, 'Adding repo_url of php for debian') - EERepo.add(self, repo_url=EEVariables.ee_php_repo) - Log.debug(self, 'Adding Dotdeb/php GPG key') - EERepo.add_key(self, '89DF5277') + if EEVariables.ee_platform_codename is not 'jessie': + Log.debug(self, 'Adding repo_url of php for debian') + EERepo.add(self, repo_url=EEVariables.ee_php_repo) + Log.debug(self, 'Adding Dotdeb/php GPG key') + EERepo.add_key(self, '89DF5277') else: Log.debug(self, 'Adding ppa for PHP') EERepo.add(self, ppa=EEVariables.ee_php_repo) From 6c70b0784dea171386f5697fe0da0918914c41e4 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 11 May 2015 16:02:04 +0530 Subject: [PATCH 03/14] added jessie support in install script --- ee/cli/plugins/stack.py | 2 +- install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 7e9d652e..5d242489 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -162,7 +162,7 @@ class EEStackController(CementBaseController): Log.info(self, "Adding repository for PHP, please wait...") # Add repository for php if EEVariables.ee_platform_distro == 'debian': - if EEVariables.ee_platform_codename is not 'jessie': + if EEVariables.ee_platform_codename != 'jessie': Log.debug(self, 'Adding repo_url of php for debian') EERepo.add(self, repo_url=EEVariables.ee_php_repo) Log.debug(self, 'Adding Dotdeb/php GPG key') diff --git a/install b/install index 2ca76cf7..c7a1648e 100644 --- a/install +++ b/install @@ -63,7 +63,7 @@ if [ "$ee_linux_distro" != "Ubuntu" ] && [ "$ee_linux_distro" != "Debian" ]; the fi # EasyEngine (ee) only support all Ubuntu/Debian distro except the distro reached EOL -lsb_release -d | egrep -e "12.04|14.04|wheezy" &>> /dev/null +lsb_release -d | egrep -e "12.04|14.04|wheezy|jessie" &>> /dev/null if [ "$?" -ne "0" ]; then ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04 and Debian 7.x" exit 100 From 8b89d434cf03a35cf4ae9f4aaa9f8461442f713d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 11 May 2015 16:03:08 +0530 Subject: [PATCH 04/14] Fixed issue where upstream hhvm causing site failure --- ee/cli/plugins/site_functions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index f51cdcb8..bbb7783d 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -630,6 +630,13 @@ def site_package_check(self, stype): out=ee_nginx) ee_nginx.close() + if os.path.isfile("/etc/nginx/conf.d/upstream.conf"): + if not EEFileUtils.grep(self, "/etc/nginx/conf.d/upstream.conf", + "hhvm"): + with open("/etc/nginx/conf.d/upstream.conf", "a") as hhvm_file: + hhvm_file.write("upstream hhvm {\nserver 127.0.0.1:8000;\n" + "server 127.0.0.1:9000 backup;\n}\n") + # Check if Nginx is allready installed and Pagespeed config there or not # If not then copy pagespeed config if self.app.pargs.pagespeed: From 53c5069dae5a2a395eb5d807458919ef0dce9f88 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 11 May 2015 18:39:59 +0530 Subject: [PATCH 05/14] Updated MySQLTuner to fix issue MariaDB conflict --- ee/cli/plugins/stack.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 5d242489..0e59f405 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -719,6 +719,9 @@ class EEStackController(CementBaseController): except CommandExecutionError as e: Log.error(self, "Unable to update MySQL file") + # Set MySQLTuner permission + EEFileUtils.chmod(self, "/usr/bin/mysqltunner", 0o775) + EEGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git") EEService.reload_service(self, 'mysql') @@ -1486,6 +1489,13 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting apt_packages variable for MySQL") if not EEShellExec.cmd_exec(self, "mysqladmin ping"): apt_packages = apt_packages + EEVariables.ee_mysql + packages = packages + [["https://raw." + "githubusercontent.com/" + "major/MySQLTuner-perl" + "/master/mysqltuner.pl", + "/usr/bin/mysqltuner", + "MySQLTuner"]] + else: Log.debug(self, "MySQL connection is already alive") Log.info(self, "MySQL connection is already alive") @@ -1671,6 +1681,7 @@ class EEStackController(CementBaseController): if self.app.pargs.mysql: Log.debug(self, "Removing apt_packages variable of MySQL") apt_packages = apt_packages + EEVariables.ee_mysql + packages = packages + ['/usr/bin/mysqltuner'] if self.app.pargs.postfix: Log.debug(self, "Removing apt_packages variable of Postfix") apt_packages = apt_packages + EEVariables.ee_postfix @@ -1784,6 +1795,7 @@ class EEStackController(CementBaseController): if self.app.pargs.mysql: Log.debug(self, "Purge apt_packages variable MySQL") apt_packages = apt_packages + EEVariables.ee_mysql + packages = packages + ['/usr/bin/mysqltuner'] if self.app.pargs.postfix: Log.debug(self, "Purge apt_packages variable PostFix") apt_packages = apt_packages + EEVariables.ee_postfix From 2739d229e9213cfbd6db12dea2689e377ec66709 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 11 May 2015 18:40:51 +0530 Subject: [PATCH 06/14] Removed MySQLtuner from global variable --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 7c4cb57f..4461a910 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -107,7 +107,7 @@ class EEVariables(): ee_mysql_repo = ("deb http://mirror.aarnet.edu.au/pub/MariaDB/repo/" "10.0/debian {codename} main" .format(codename=ee_platform_codename)) - ee_mysql = ["mariadb-server", "mysqltuner", "percona-toolkit"] + ee_mysql = ["mariadb-server", "percona-toolkit"] # Postfix repo and packages ee_postfix_repo = "" From d40dcb7a666e56e294c2b0493e5ff7a14d39e84a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 11 May 2015 18:56:18 +0530 Subject: [PATCH 07/14] Fixed Typos --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 0e59f405..c13d0b7d 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -720,7 +720,7 @@ class EEStackController(CementBaseController): Log.error(self, "Unable to update MySQL file") # Set MySQLTuner permission - EEFileUtils.chmod(self, "/usr/bin/mysqltunner", 0o775) + EEFileUtils.chmod(self, "/usr/bin/mysqltuner", 0o775) EEGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git") EEService.reload_service(self, 'mysql') From 05acb9d589f9b3337335aaed4a31166e14826b89 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 11 May 2015 19:01:43 +0530 Subject: [PATCH 08/14] updated php5-xdebug install method on jessie and removed mysqltuner package from mysql stack --- ee/cli/plugins/stack.py | 14 ++++++++------ ee/core/variables.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 5d242489..b2907bf1 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -102,11 +102,12 @@ class EEStackController(CementBaseController): with open('/etc/apt/preferences.d/' 'MariaDB.pref', 'w') as mysql_pref_file: mysql_pref_file.write(mysql_pref) - EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) - Log.debug(self, 'Adding key for {0}' - .format(EEVariables.ee_mysql_repo)) - EERepo.add_key(self, '0xcbcb082a1bb943db', - keyserver="keyserver.ubuntu.com") + if EEVariables.ee_platform_codename != 'jessie': + EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) + Log.debug(self, 'Adding key for {0}' + .format(EEVariables.ee_mysql_repo)) + EERepo.add_key(self, '0xcbcb082a1bb943db', + keyserver="keyserver.ubuntu.com") chars = ''.join(random.sample(string.ascii_letters, 8)) Log.debug(self, "Pre-seeding MySQL") Log.debug(self, "echo \"mariadb-server-10.0 " @@ -479,7 +480,8 @@ class EEStackController(CementBaseController): # For debian install xdebug - if EEVariables.ee_platform_distro == "debian": + if (EEVariables.ee_platform_distro == "debian" and + EEVariables.ee_platform_distro == 'wheezy'): EEShellExec.cmd_exec(self, "pecl install xdebug") with open("/etc/php5/mods-available/xdebug.ini", diff --git a/ee/core/variables.py b/ee/core/variables.py index 7c4cb57f..b3dbc1e3 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -95,7 +95,7 @@ class EEVariables(): "php5-mysql", "php5-cli", "php5-memcache", "php5-imagick", "memcached", "graphviz", "php-pear", "php5-dev"] - if ee_platform_distro == 'Ubuntu': + if ee_platform_distro == 'Ubuntu' or ee_platform_codename == 'jessie': ee_php = ee_php + ["php5-xdebug"] # MySQL repo and packages @@ -107,7 +107,7 @@ class EEVariables(): ee_mysql_repo = ("deb http://mirror.aarnet.edu.au/pub/MariaDB/repo/" "10.0/debian {codename} main" .format(codename=ee_platform_codename)) - ee_mysql = ["mariadb-server", "mysqltuner", "percona-toolkit"] + ee_mysql = (["mariadb-server", "percona-toolkit"]) # Postfix repo and packages ee_postfix_repo = "" From 993a0ab026b8b3ddbd375d289615239d97dda6cf Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 12 May 2015 11:36:39 +0530 Subject: [PATCH 09/14] Fixed issue where mysqltuner is not downloading while site creation --- ee/cli/plugins/site_functions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index bbb7783d..333b982e 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -576,6 +576,10 @@ def site_package_check(self, stype): Log.debug(self, "Setting apt_packages variable for MySQL") if not EEShellExec.cmd_exec(self, "mysqladmin ping"): apt_packages = apt_packages + EEVariables.ee_mysql + packages = packages + [["https://raw.githubusercontent.com/" + "major/MySQLTuner-perl/master/" + "mysqltuner.pl", "/usr/bin/mysqltuner", + "MySQLTuner"]] if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: Log.debug(self, "Setting apt_packages variable for Postfix") From 79ffd96deef7990d12155ceb490891a975692fff Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 13 May 2015 11:32:28 +0530 Subject: [PATCH 10/14] lowercase distros --- ee/cli/plugins/secure.py | 2 +- ee/cli/plugins/stack.py | 6 +++--- ee/cli/plugins/stack_upgrade.py | 4 ++-- ee/core/apt_repo.py | 2 +- ee/core/variables.py | 13 ++++++------- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 02c20bb3..ad32c40e 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -93,7 +93,7 @@ class EESecureController(CementBaseController): Log.info(self, "Please Enter valid port number :") port = input("EasyEngine admin port [22222]:") self.app.pargs.user_input = port - if EEVariables.ee_platform_distro == 'Ubuntu': + if EEVariables.ee_platform_distro == 'ubuntu': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl spdy;/\" " "/etc/nginx/sites-available/22222" diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9b851cec..36540e66 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -221,7 +221,7 @@ class EEStackController(CementBaseController): nc.savef('/etc/nginx/nginx.conf') # Custom Nginx configuration by EasyEngine - if EEVariables.ee_platform_distro == 'Ubuntu': + if EEVariables.ee_platform_distro == 'ubuntu': data = dict(version=EEVariables.ee_version, Ubuntu=True) else: @@ -481,7 +481,7 @@ class EEStackController(CementBaseController): # For debian install xdebug if (EEVariables.ee_platform_distro == "debian" and - EEVariables.ee_platform_distro == 'wheezy'): + EEVariables.ee_platform_codename == 'wheezy'): EEShellExec.cmd_exec(self, "pecl install xdebug") with open("/etc/php5/mods-available/xdebug.ini", @@ -1461,7 +1461,7 @@ class EEStackController(CementBaseController): if self.app.pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") - if EEVariables.ee_platform_distro == 'Debian': + if EEVariables.ee_platform_distro == 'debian': check_nginx = 'nginx-extras' else: check_nginx = 'nginx-custom' diff --git a/ee/cli/plugins/stack_upgrade.py b/ee/cli/plugins/stack_upgrade.py index 1bfe07e3..4c9eac0a 100644 --- a/ee/cli/plugins/stack_upgrade.py +++ b/ee/cli/plugins/stack_upgrade.py @@ -48,7 +48,7 @@ class EEStackUpgradeController(CementBaseController): @expose(hide=True) def upgrade_php56(self): - if EEVariables.ee_platform_distro == "Ubuntu": + if EEVariables.ee_platform_distro == "ubuntu": if os.path.isfile("/etc/apt/sources.list.d/ondrej-php5-5_6-{0}." "list".format(EEVariables.ee_platform_codename)): Log.error(self, "Unable to find PHP 5.5") @@ -67,7 +67,7 @@ class EEStackUpgradeController(CementBaseController): if start_upgrade != "Y" and start_upgrade != "y": Log.error(self, "Not starting PHP package update") - if EEVariables.ee_platform_distro == "Ubuntu": + if EEVariables.ee_platform_distro == "ubuntu": EERepo.remove(self, ppa="ppa:ondrej/php5") EERepo.add(self, ppa=EEVariables.ee_php_repo) else: diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index ecfd4cfc..601a88cc 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -47,7 +47,7 @@ class EERepo(): Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to add repo") if ppa is not None: - if EEVariables.ee_platform_distro == 'squeeze': + if EEVariables.ee_platform_codename == 'squeeze': print("Cannot add repo for {distro}" .format(distro=EEVariables.ee_platform_distro)) else: diff --git a/ee/core/variables.py b/ee/core/variables.py index ad7e1344..ceb7b0b4 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -24,7 +24,7 @@ class EEVariables(): ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') # EasyEngine core variables - ee_platform_distro = platform.linux_distribution()[0] + ee_platform_distro = platform.linux_distribution()[0].lower() ee_platform_version = platform.linux_distribution()[1] ee_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read() @@ -76,7 +76,7 @@ class EEVariables(): # EasyEngine stack installation varibales # Nginx repo and packages - if ee_platform_distro == 'Ubuntu': + if ee_platform_distro == 'ubuntu': ee_nginx_repo = "ppa:rtcamp/nginx" ee_nginx = ["nginx-custom", "nginx-common"] elif ee_platform_distro == 'debian': @@ -85,7 +85,7 @@ class EEVariables(): ee_nginx = ["nginx-extras", "nginx-common"] # PHP repo and packages - if ee_platform_distro == 'Ubuntu': + if ee_platform_distro == 'ubuntu': ee_php_repo = "ppa:ondrej/php5-5.6" elif ee_platform_codename == 'wheezy': ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php56 all" @@ -95,11 +95,11 @@ class EEVariables(): "php5-mysql", "php5-cli", "php5-memcache", "php5-imagick", "memcached", "graphviz", "php-pear", "php5-dev"] - if ee_platform_distro == 'Ubuntu' or ee_platform_codename == 'jessie': + if ee_platform_distro == 'ubuntu' or ee_platform_codename == 'jessie': ee_php = ee_php + ["php5-xdebug"] # MySQL repo and packages - if ee_platform_distro == 'Ubuntu': + if ee_platform_distro == 'ubuntu': ee_mysql_repo = ("deb http://mirror.aarnet.edu.au/pub/MariaDB/repo/" "10.0/ubuntu {codename} main" .format(codename=ee_platform_codename)) @@ -110,7 +110,6 @@ class EEVariables(): ee_mysql = ["mariadb-server", "percona-toolkit"] - # Postfix repo and packages ee_postfix_repo = "" ee_postfix = ["postfix"] @@ -132,7 +131,7 @@ class EEVariables(): # HHVM repo details # 12.04 requires boot repository - if ee_platform_distro == 'Ubuntu': + if ee_platform_distro == 'ubuntu': if ee_platform_codename == "precise": ee_boost_repo = ("ppa:mapnik/boost") From f566f9863598fd836ff66065ae9237e3f307ded4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 13 May 2015 12:51:02 +0530 Subject: [PATCH 11/14] Now if nginx reload failed then it will stop the executation during ee stack install --- ee/cli/plugins/stack.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9b851cec..51dc52c5 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -691,7 +691,9 @@ class EEStackController(CementBaseController): out=ee_nginx) ee_nginx.close() - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "Failed to reload Nginx, please check " + "output of `nginx -t`") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): # TODO: Currently we are using, we need to remove it in future From 2e27829ccffb9574e6ad04f4919b2ca93a8b326d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 13 May 2015 14:13:48 +0530 Subject: [PATCH 12/14] exit and throw error when nginx reload fails --- ee/cli/plugins/secure.py | 4 ++- ee/cli/plugins/site.py | 63 +++++++++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index ad32c40e..ee1f069f 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -105,7 +105,9 @@ class EESecureController(CementBaseController): .format(port=self.app.pargs.user_input)) EEGit.add(self, ["/etc/nginx"], msg="Adding changed secure port into Git") - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") Log.info(self, "Successfully port changed {port}" .format(port=self.app.pargs.user_input)) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 54a130e0..c5fc7dca 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -69,7 +69,9 @@ class EESiteController(CementBaseController): .format(ee_domain)) updateSiteInfo(self, ee_domain, enabled=True) Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") else: Log.error(self, "nginx configuration file does not exist" .format(ee_domain)) @@ -107,7 +109,9 @@ class EESiteController(CementBaseController): .format(ee_domain)) updateSiteInfo(self, ee_domain, enabled=False) Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") else: Log.error(self, "nginx configuration file does not exist" .format(ee_domain)) @@ -277,7 +281,9 @@ class EESiteEditController(CementBaseController): EEGit.add(self, ["/etc/nginx"], msg="Edit website: {0}" .format(ee_domain)) # Reload NGINX - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") else: Log.error(self, "nginx configuration file does not exists" .format(ee_domain)) @@ -298,7 +304,9 @@ class EESiteEditController(CementBaseController): msg="Edit Pagespped config of site: {0}" .format(ee_domain)) # Reload NGINX - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") else: Log.error(self, "Pagespeed configuration file does not exists" .format(ee_domain)) @@ -499,7 +507,15 @@ class EESiteCreateController(CementBaseController): if 'proxy' in data.keys() and data['proxy']: addNewSite(self, ee_domain, stype, cache, ee_site_webroot) # Service Nginx Reload - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.info(self, Log.FAIL + "Oops Something went wrong !!") + Log.info(self, Log.FAIL + "Calling cleanup actions ...") + doCleanupAction(self, domain=ee_domain) + Log.debug(self, str(e)) + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") + Log.error(self, "Check logs for reason " + "`tail /var/log/ee/ee.log` & Try Again!!!") if ee_auth and len(ee_auth): for msg in ee_auth: Log.info(self, Log.ENDC + msg, log=False) @@ -588,8 +604,22 @@ class EESiteCreateController(CementBaseController): Log.error(self, "Check logs for reason " "`tail /var/log/ee/ee.log` & Try Again!!!") - # Service Nginx Reload - EEService.reload_service(self, 'nginx') + # Service Nginx Reload call cleanup if failed to reload nginx + if not EEService.reload_service(self, 'nginx'): + Log.info(self, Log.FAIL + "Oops Something went wrong !!") + Log.info(self, Log.FAIL + "Calling cleanup actions ...") + doCleanupAction(self, domain=ee_domain, + webroot=data['webroot']) + if 'ee_db_name' in data.keys(): + doCleanupAction(self, domain=ee_domain, + dbname=data['ee_db_name'], + dbuser=data['ee_db_user'], + dbhost=data['ee_db_host']) + deleteSiteInfo(self, ee_domain) + Log.info(self, Log.FAIL + "service nginx reload failed." + " check issues with `nginx -t` command.") + Log.error(self, "Check logs for reason " + "`tail /var/log/ee/ee.log` & Try Again!!!") EEGit.add(self, ["/etc/nginx"], msg="{0} created with {1} {2}" @@ -602,10 +632,13 @@ class EESiteCreateController(CementBaseController): Log.info(self, Log.FAIL + "Oops Something went wrong !!") Log.info(self, Log.FAIL + "Calling cleanup actions ...") doCleanupAction(self, domain=ee_domain, - webroot=data['webroot'], - dbname=data['ee_db_name'], - dbuser=data['ee_db_user'], - dbhost=data['ee_db_host']) + webroot=data['webroot']) + if 'ee_db_name' in data.keys(): + print("Inside db cleanup") + doCleanupAction(self, domain=ee_domain, + dbname=data['ee_db_name'], + dbuser=data['ee_db_user'], + dbhost=data['ee_db_host']) deleteSiteInfo(self, ee_domain) Log.error(self, "Check logs for reason " "`tail /var/log/ee/ee.log` & Try Again!!!") @@ -985,7 +1018,9 @@ class EESiteUpdateController(CementBaseController): if stype == oldsitetype and cache == oldcachetype: # Service Nginx Reload - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") updateSiteInfo(self, ee_domain, stype=stype, cache=cache, hhvm=hhvm, pagespeed=pagespeed) @@ -1090,7 +1125,9 @@ class EESiteUpdateController(CementBaseController): "`tail /var/log/ee/ee.log` & Try Again!!!") return 1 # Service Nginx Reload - EEService.reload_service(self, 'nginx') + if not EEService.reload_service(self, 'nginx'): + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") EEGit.add(self, ["/etc/nginx"], msg="{0} updated with {1} {2}" From 50673867d4e64c23dcbedd81a4b85b62ec0a4e39 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 13 May 2015 17:23:31 +0530 Subject: [PATCH 13/14] Fix for Nginx white screen of death, fixes #538 --- ee/cli/plugins/site_functions.py | 8 ++++++++ ee/cli/plugins/stack.py | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 333b982e..782a8eba 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -566,6 +566,14 @@ def site_package_check(self, stype): if not EEAptGet.is_installed(self, check_nginx): apt_packages = apt_packages + EEVariables.ee_nginx + else: + # Fix for Nginx white screen death + if not EEFileUtils.grep(self, '/etc/nginx/fastcgi_params', + 'SCRIPT_FILENAME'): + with open('/etc/nginx/fastcgi_params', encoding='utf-8', + mode='a') as ee_nginx: + ee_nginx.write('fastcgi_param \tSCRIPT_FILENAME ' + '\t$request_filename;') if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: Log.debug(self, "Setting apt_packages variable for PHP") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 63b50308..2bb80ed5 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -361,6 +361,17 @@ class EEStackController(CementBaseController): out=ee_nginx) ee_nginx.close() + # Fix whitescreen of death beacuse of missing value + # fastcgi_param SCRIPT_FILENAME $request_filename; in file + # /etc/nginx/fastcgi_params + + if not EEFileUtils.grep(self, '/etc/nginx/fastcgi_params', + 'SCRIPT_FILENAME'): + with open('/etc/nginx/fastcgi_params', + encoding='utf-8', mode='a') as ee_nginx: + ee_nginx.write('fastcgi_param \tSCRIPT_FILENAME ' + '\t$request_filename;') + # Pagespeed configuration Log.debug(self, 'Writting the Pagespeed Global ' 'configuration to file /etc/nginx/conf.d/' From 53be1a9290be87b118437c9a868a72f412aa84fa Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 13 May 2015 17:43:38 +0530 Subject: [PATCH 14/14] Fixed debug is not get disabled after clossing interactive debug --- ee/cli/plugins/debug.py | 6 ++++++ ee/cli/plugins/site_functions.py | 2 +- ee/cli/plugins/stack.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 7d5f20b7..9af9ee46 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -454,21 +454,27 @@ class EEDebugController(CementBaseController): """Handle Ctrl+c hevent 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.fpm: + self.app.pargs.fpm = 'off' self.debug_fpm() if self.app.pargs.mysql: # MySQL debug will not work for remote MySQL if EEVariables.ee_mysql_host is "localhost": + self.app.pargs.mysql = 'off' self.debug_mysql() else: Log.warn(self, "Remote MySQL found, EasyEngine will not " "enable remote debug") 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 diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 782a8eba..d082a6e3 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -573,7 +573,7 @@ def site_package_check(self, stype): with open('/etc/nginx/fastcgi_params', encoding='utf-8', mode='a') as ee_nginx: ee_nginx.write('fastcgi_param \tSCRIPT_FILENAME ' - '\t$request_filename;') + '\t$request_filename;\n') if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: Log.debug(self, "Setting apt_packages variable for PHP") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 2bb80ed5..64f0eec8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -370,7 +370,7 @@ class EEStackController(CementBaseController): with open('/etc/nginx/fastcgi_params', encoding='utf-8', mode='a') as ee_nginx: ee_nginx.write('fastcgi_param \tSCRIPT_FILENAME ' - '\t$request_filename;') + '\t$request_filename;\n') # Pagespeed configuration Log.debug(self, 'Writting the Pagespeed Global '