Commit e2c00a17 authored by Falko Timme's avatar Falko Timme

- Added restart function for PHP-FPM.

parent dc48ab33
......@@ -101,6 +101,7 @@ class web_module {
// Register service
$app->services->registerService('httpd','web_module','restartHttpd');
$app->services->registerService('php-fpm','web_module','restartPHP_FPM');
}
......@@ -164,9 +165,6 @@ class web_module {
switch ($web_config['server_type']) {
case 'nginx':
$daemon = $web_config['server_type'];
// Reload PHP-FPM as well
$restart_second_service['daemon'] = $web_config['php_fpm_init_script'];
$restart_second_service['action'] = 'reload';
break;
default:
if(is_file($conf['init_scripts'] . '/' . 'httpd')) {
......@@ -175,11 +173,7 @@ class web_module {
$daemon = 'apache2';
}
}
if($restart_second_service['daemon'] != '' && $restart_second_service['action'] != ''){
exec($conf['init_scripts'] . '/' . $restart_second_service['daemon'] . ' ' . $restart_second_service['action']);
}
if($action == 'restart') {
exec($conf['init_scripts'] . '/' . $daemon . ' restart');
} else {
......@@ -187,6 +181,20 @@ class web_module {
}
}
function restartPHP_FPM($action = 'restart') {
global $app,$conf;
// load the server configuration options
$app->uses('getconf');
$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
list($action, $init_script) = explode(':', $action);
if(!$init_script) $init_script = $conf['init_scripts'].'/'.$web_config['php_fpm_init_script'];
exec($init_script.' '.$action);
}
} // end class
......
......@@ -1407,18 +1407,25 @@ class nginx_plugin {
$default_php_fpm = true;
}
$app->uses("getconf");
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
if($data['new']['php'] == 'no'){
if(@is_file($pool_dir.$pool_name.'.conf')){
unlink($pool_dir.$pool_name.'.conf');
//$reload = true;
}
if($data['old']['php'] != 'no'){
if(!$default_php_fpm){
$app->services->restartService('php-fpm','reload:'.$custom_php_fpm_init_script);
} else {
$app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
}
}
//if($reload == true) $app->services->restartService('php-fpm','reload');
return;
}
$app->uses("getconf");
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
$app->load('tpl');
$tpl = new tpl();
$tpl->newTemplate('php_fpm_pool.conf.master');
......@@ -1503,7 +1510,7 @@ class nginx_plugin {
if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
unlink($default_pool_dir.$pool_name.'.conf');
$app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
exec($conf['init_scripts'] . '/' . $web_config['php_fpm_init_script'] . ' reload');
$app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
}
}
$php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$conf["server_id"]);
......@@ -1514,15 +1521,17 @@ class nginx_plugin {
if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
$app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG);
exec($php_version['php_fpm_init_script'] . ' reload');
$app->services->restartService('php-fpm','reload:'.$php_version['php_fpm_init_script']);
}
}
}
}
// Reload current PHP-FPM after all others
sleep(1);
if(!$default_php_fpm){
sleep(1);
exec($custom_php_fpm_init_script . ' reload');
$app->services->restartService('php-fpm','reload:'.$custom_php_fpm_init_script);
} else {
$app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
}
//$reload = true;
......@@ -1565,7 +1574,7 @@ class nginx_plugin {
if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
unlink($default_pool_dir.$pool_name.'.conf');
$app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf',LOGLEVEL_DEBUG);
exec($conf['init_scripts'] . '/' . $web_config['php_fpm_init_script'] . ' reload');
$app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
}
}
$php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$data['old']['server_id']);
......@@ -1576,16 +1585,18 @@ class nginx_plugin {
if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
unlink($php_version['php_fpm_pool_dir'].$pool_name.'.conf');
$app->log('Removed PHP-FPM config file: '.$php_version['php_fpm_pool_dir'].$pool_name.'.conf',LOGLEVEL_DEBUG);
exec($php_version['php_fpm_init_script'] . ' reload');
$app->services->restartService('php-fpm','reload:'.$php_version['php_fpm_init_script']);
}
}
}
}
// Reload current PHP-FPM after all others
sleep(1);
if(!$default_php_fpm){
sleep(1);
exec($custom_php_fpm_init_script . ' reload');
$app->services->restartService('php-fpm','reload:'.$custom_php_fpm_init_script);
} else {
$app->services->restartService('php-fpm','reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment