Skip to content

Commit 6d6643d

Browse files
author
Till Brehm
committed
Fixed service restart problems on CentOS 7.
1 parent 9b021b2 commit 6d6643d

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

server/lib/classes/system.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ function is_mounted($mountpoint){
17221722
function getinitcommand($servicename, $action, $init_script_directory = ''){
17231723
global $conf;
17241724
// systemd
1725-
if(is_executable('/bin/systemd')){
1725+
if(is_executable('/bin/systemd') || is_executable('/usr/bin/systemctl')){
17261726
return 'systemctl '.$action.' '.$servicename.'.service';
17271727
}
17281728
// upstart

server/mods-available/web_module.inc.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,12 @@ function restartHttpd($action = 'restart') {
212212

213213
$retval = array('output' => '', 'retval' => 0);
214214
if($action == 'restart') {
215-
exec($app->system->getinitcommand($daemon, 'restart').' 2>&1', $retval['output'], $retval['retval']);
216-
215+
$cmd = $app->system->getinitcommand($daemon, 'restart');
217216
} else {
218-
exec($app->system->getinitcommand($daemon, 'reload').' 2>&1', $retval['output'], $retval['retval']);
217+
$cmd = $app->system->getinitcommand($daemon, 'reload');
219218
}
219+
exec($cmd.' 2>&1', $retval['output'], $retval['retval']);
220+
$app->log("Restarting httpd: $cmd", LOGLEVEL_DEBUG);
220221

221222
// 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?)
222223
if($web_config['server_type'] == 'nginx' && $retval['retval'] == 0){
@@ -249,13 +250,30 @@ function restartPHP_FPM($action = 'restart') {
249250
if(preg_match('/^ID=ubuntu/m', $tmp) && preg_match('/^VERSION_ID="14\.04"/m', $tmp)) {
250251
$initcommand = '/sbin/start-stop-daemon --stop --signal USR2 --quiet --pidfile /var/run/php5-fpm.pid --name php5-fpm';
251252
}
253+
// And the next workaround, php-fpm reloads in centos 7 downt work as well.
254+
if(preg_match('/^ID=centos/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) {
255+
$initcommand = 'systemctl restart php-fpm.service';
256+
}
257+
unset($tmp);
258+
}
259+
}
260+
261+
if($action == 'reload') {
262+
// And the next workaround, php-fpm reloads in centos 7 downt work as well.
263+
if(file_exists('/etc/os-release')) {
264+
$tmp = file_get_contents('/etc/os-release');
265+
// And the next workaround, php-fpm reloads in centos 7 downt work as well.
266+
if(preg_match('/^ID="centos"/m', $tmp) && preg_match('/^VERSION_ID="7"/m', $tmp)) {
267+
$initcommand = 'systemctl restart php-fpm.service';
268+
}
252269
unset($tmp);
253270
}
254271
}
255272
}
256273

257274
$retval = array('output' => '', 'retval' => 0);
258275
exec($initcommand.' 2>&1', $retval['output'], $retval['retval']);
276+
$app->log("Restarting php-fpm: $initcommand", LOGLEVEL_DEBUG);
259277
return $retval;
260278
}
261279

0 commit comments

Comments
 (0)