Commit 3b0f4a4d authored by Till Brehm's avatar Till Brehm

Added PHP-FPM Restart mode. See System > Interface config > Web > PHP-FPM reload mode. Fixes #4816

parent faff70ca
......@@ -116,6 +116,7 @@ overquota_db_notify_admin=y
overquota_db_notify_client=y
overquota_notify_onok=n
logging=yes
php_fpm_reload_mode=reload
[dns]
bind_user=root
......
......@@ -1376,6 +1376,14 @@ $form["tabs"]['web'] = array(
1 => 'y'
)
),
'php_fpm_reload_mode' => array(
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'reload',
'value' => array('reload' => 'Reload', 'restart' => 'Restart'),
'width' => '40',
'maxlength' => '255'
),
//#################################
// ENDE Datatable fields
//#################################
......
......@@ -295,4 +295,5 @@ $wb['log_retention_error_ispositive'] = 'Log retention must be a number > 0';
$wb['php_default_name_txt'] = 'Beschreibung Standard PHP';
$wb['php_default_name_error_empty'] = 'Beschreibung Standard PHP ist leer.';
$wb['error_mailbox_message_size_txt'] = 'Mailboxgröße muss gleich oder größer als max. Nachrichtengröße sein.';
$wb['php_fpm_reload_mode_txt'] = 'PHP-FPM reload Modus';
?>
......@@ -296,4 +296,5 @@ $wb['log_retention_error_ispositive'] = 'Log retention must be a number > 0';
$wb['php_default_name_txt'] = 'Description Default PHP-Version';
$wb['php_default_name_error_empty'] = 'Description Default PHP-Version must not be empty';
$wb['error_mailbox_message_size_txt'] = 'Mailbox size must be larger or equal to message size';
$wb['php_fpm_reload_mode_txt'] = 'PHP-FPM reload mode';
?>
......@@ -299,6 +299,12 @@
{tmpl_var name='php_fpm_incron_reload'}
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='php_fpm_reload_mode_txt'}</label>
<div class="col-sm-9"><select name="php_fpm_reload_mode" id="php_fpm_reload_mode" class="form-control">
{tmpl_var name='php_fpm_reload_mode'}
</select></div>
</div>
<!-- End content -->
</div>
</div>
......
......@@ -3058,6 +3058,8 @@ class apache2_plugin {
$app->uses("getconf");
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
$php_fpm_reload_mode = ($web_config['php_fpm_reload_mode'] == 'reload')?'reload':'restart';
if($data['new']['php'] != 'php-fpm'){
if(@is_file($pool_dir.$pool_name.'.conf')){
......@@ -3066,9 +3068,9 @@ class apache2_plugin {
}
if($data['old']['php'] == 'php-fpm'){
if(!$default_php_fpm){
$app->services->restartService('php-fpm', 'reload:'.$custom_php_fpm_init_script);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$custom_php_fpm_init_script);
} else {
$app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
}
}
//if($reload == true) $app->services->restartService('php-fpm','reload');
......@@ -3205,7 +3207,7 @@ class apache2_plugin {
if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
$app->system->unlink($default_pool_dir.$pool_name.'.conf');
$app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf', LOGLEVEL_DEBUG);
$app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$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"]);
......@@ -3217,7 +3219,7 @@ class apache2_plugin {
if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
$app->system->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);
$app->services->restartService('php-fpm', 'reload:'.$php_version['php_fpm_init_script']);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$php_version['php_fpm_init_script']);
}
}
}
......@@ -3225,9 +3227,9 @@ class apache2_plugin {
// Reload current PHP-FPM after all others
sleep(1);
if(!$default_php_fpm){
$app->services->restartService('php-fpm', 'reload:'.$custom_php_fpm_init_script);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$custom_php_fpm_init_script);
} else {
$app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
}
//$reload = true;
......@@ -3238,6 +3240,11 @@ class apache2_plugin {
//* Delete the PHP-FPM pool configuration file
private function php_fpm_pool_delete ($data, $web_config) {
global $app, $conf;
$app->uses("getconf");
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
$php_fpm_reload_mode = ($web_config['php_fpm_reload_mode'] == 'reload')?'reload':'restart';
if(trim($data['old']['fastcgi_php_version']) != '' && $data['old']['php'] == 'php-fpm'){
$default_php_fpm = false;
......@@ -3271,7 +3278,7 @@ class apache2_plugin {
if ( @is_file($default_pool_dir.$pool_name.'.conf') ) {
$app->system->unlink($default_pool_dir.$pool_name.'.conf');
$app->log('Removed PHP-FPM config file: '.$default_pool_dir.$pool_name.'.conf', LOGLEVEL_DEBUG);
$app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$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']);
......@@ -3283,7 +3290,7 @@ class apache2_plugin {
if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) {
$app->system->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);
$app->services->restartService('php-fpm', 'reload:'.$php_version['php_fpm_init_script']);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$php_version['php_fpm_init_script']);
}
}
}
......@@ -3292,9 +3299,9 @@ class apache2_plugin {
// Reload current PHP-FPM after all others
sleep(1);
if(!$default_php_fpm){
$app->services->restartService('php-fpm', 'reload:'.$custom_php_fpm_init_script);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$custom_php_fpm_init_script);
} else {
$app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']);
$app->services->restartService('php-fpm', $php_fpm_reload_mode.':'.$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