From 4569cae57f127afd093794310ccd290d2d9fdf36 Mon Sep 17 00:00:00 2001 From: Marius Burkard <m.burkard@pixcept.de> Date: Wed, 20 Apr 2016 10:58:46 -0400 Subject: [PATCH] Merge branch 'stable-3.1' --- server/mods-available/web_module.inc.php | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/server/mods-available/web_module.inc.php b/server/mods-available/web_module.inc.php index 42eaab6..6d3e8c1 100644 --- a/server/mods-available/web_module.inc.php +++ b/server/mods-available/web_module.inc.php @@ -216,13 +216,31 @@ } else { $cmd = $app->system->getinitcommand($daemon, 'reload'); } + + if($web_config['server_type'] == 'nginx'){ + $app->log("Checking nginx configuration...", LOGLEVEL_DEBUG); + exec('nginx -t 2>&1', $retval['output'], $retval['retval']); + if($retval['retval'] == 0){ + $app->log("nginx configuration ok!", LOGLEVEL_DEBUG); + } else { + $app->log("nginx config test failed!", LOGLEVEL_DEBUG); + return $retval; + } + } + exec($cmd.' 2>&1', $retval['output'], $retval['retval']); + + // if restart failed despite successful syntax check => try again + if($web_config['server_type'] == 'nginx' && $retval['retval'] > 0){ + sleep(2); + exec($cmd.' 2>&1', $retval['output'], $retval['retval']); + } $app->log("Restarting httpd: $cmd", LOGLEVEL_DEBUG); // nginx: do a syntax check because on some distributions, the init script always returns 0 - even if the syntax is not ok (how stupid is that?) - if($web_config['server_type'] == 'nginx' && $retval['retval'] == 0){ - exec('nginx -t 2>&1', $retval['output'], $retval['retval']); - } + //if($web_config['server_type'] == 'nginx' && $retval['retval'] == 0){ + //exec('nginx -t 2>&1', $retval['output'], $retval['retval']); + //} return $retval; } @@ -247,17 +265,20 @@ // @see: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376 if(file_exists('/etc/os-release')) { $tmp = file_get_contents('/etc/os-release'); - if(preg_match('/^ID=ubuntu/m', $tmp) && preg_match('/^VERSION_ID="14\.04"/m', $tmp)) { + //if(preg_match('/^ID=ubuntu/m', $tmp) && preg_match('/^VERSION_ID="14\.04"/m', $tmp)) { + if(preg_match('/^ID=ubuntu/m', $tmp) && preg_match('/^VERSION_ID="14\.04"/m', $tmp) && stristr(phpversion(), 'deb.sury.org') === false) { $initcommand = '/sbin/start-stop-daemon --stop --signal USR2 --quiet --pidfile /var/run/php5-fpm.pid --name php5-fpm'; } // And the next workaround, php-fpm reloads in centos 7 downt work as well. + /* if(preg_match('/^ID=centos/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) { $initcommand = 'systemctl restart php-fpm.service'; } + */ unset($tmp); } } - + /* if($action == 'reload') { // And the next workaround, php-fpm reloads in centos 7 downt work as well. if(file_exists('/etc/os-release')) { @@ -269,6 +290,7 @@ unset($tmp); } } + */ } $retval = array('output' => '', 'retval' => 0); -- Gitblit v1.9.1