From 5ca959fa688255a8de61f89fe2751eb4d24a6912 Mon Sep 17 00:00:00 2001 From: Florian Schaal <florian@schaal-24.de> Date: Tue, 22 Mar 2016 09:22:07 -0400 Subject: [PATCH] fixed typo --- server/mods-available/web_module.inc.php | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 42 insertions(+), 6 deletions(-) diff --git a/server/mods-available/web_module.inc.php b/server/mods-available/web_module.inc.php index 666e845..36e1391 100644 --- a/server/mods-available/web_module.inc.php +++ b/server/mods-available/web_module.inc.php @@ -203,7 +203,7 @@ $daemon = $web_config['server_type']; break; default: - if(is_file($conf['init_scripts'] . '/' . 'httpd')) { + if(is_file($conf['init_scripts'] . '/' . 'httpd') || is_dir('/etc/httpd')) { $daemon = 'httpd'; } else { $daemon = 'apache2'; @@ -212,16 +212,35 @@ $retval = array('output' => '', 'retval' => 0); if($action == 'restart') { - exec($app->system->getinitcommand($daemon, 'restart').' 2>&1', $retval['output'], $retval['retval']); - + $cmd = $app->system->getinitcommand($daemon, 'restart'); } else { - exec($app->system->getinitcommand($daemon, 'reload').' 2>&1', $retval['output'], $retval['retval']); + $cmd = $app->system->getinitcommand($daemon, 'reload'); } - // 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){ + 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']); + //} return $retval; } @@ -249,6 +268,22 @@ if(preg_match('/^ID=ubuntu/m', $tmp) && preg_match('/^VERSION_ID="14\.04"/m', $tmp)) { $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')) { + $tmp = file_get_contents('/etc/os-release'); + // 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); } } @@ -256,6 +291,7 @@ $retval = array('output' => '', 'retval' => 0); exec($initcommand.' 2>&1', $retval['output'], $retval['retval']); + $app->log("Restarting php-fpm: $initcommand", LOGLEVEL_DEBUG); return $retval; } -- Gitblit v1.9.1