Commit dd7ce475 authored by Falko Timme's avatar Falko Timme

- Implemented FS#1888 and FS#2211.

parent 76ebcb3b
ALTER TABLE `web_domain` ADD `pm` ENUM( 'static', 'dynamic', 'ondemand' ) NOT NULL DEFAULT 'dynamic' AFTER `php_fpm_use_socket`;
ALTER TABLE `web_domain` ADD `pm_process_idle_timeout` INT NOT NULL DEFAULT '10' AFTER `pm_max_spare_servers` , ADD `pm_max_requests` INT NOT NULL DEFAULT '0' AFTER `pm_process_idle_timeout`;
\ No newline at end of file
......@@ -1564,10 +1564,13 @@ CREATE TABLE `web_domain` (
`apache_directives` mediumtext,
`nginx_directives` mediumtext,
`php_fpm_use_socket` ENUM('n','y') NOT NULL DEFAULT 'n',
`pm` enum('static','dynamic','ondemand') NOT NULL DEFAULT 'dynamic',
`pm_max_children` int(11) NOT NULL DEFAULT '10',
`pm_start_servers` int(11) NOT NULL DEFAULT '2',
`pm_min_spare_servers` int(11) NOT NULL DEFAULT '1',
`pm_max_spare_servers` int(11) NOT NULL DEFAULT '5',
`pm_process_idle_timeout` int(11) NOT NULL DEFAULT '10',
`pm_max_requests` int(11) NOT NULL DEFAULT '0',
`php_open_basedir` mediumtext,
`custom_php_ini` mediumtext,
`backup_interval` VARCHAR( 255 ) NOT NULL DEFAULT 'none',
......
......@@ -542,6 +542,12 @@ $form["tabs"]['advanced'] = array (
'default' => 'n',
'value' => array(0 => 'n',1 => 'y')
),
'pm' => array (
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'dynamic',
'value' => array('static' => 'static', 'dynamic' => 'dynamic', 'ondemand' => 'ondemand (PHP Version >= 5.3.9)')
),
'pm_max_children' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
......@@ -590,6 +596,30 @@ $form["tabs"]['advanced'] = array (
'width' => '3',
'maxlength' => '3'
),
'pm_process_idle_timeout' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'REGEX',
'regex' => '/^([1-9][0-9]{0,10})$/',
'errmsg'=> 'pm_process_idle_timeout_error_regex'),
),
'default' => '10',
'value' => '',
'width' => '3',
'maxlength' => '6'
),
'pm_max_requests' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'REGEX',
'regex' => '/^([0-9]{1,11})$/',
'errmsg'=> 'pm_max_requests_error_regex'),
),
'default' => '0',
'value' => '',
'width' => '3',
'maxlength' => '6'
),
'php_open_basedir' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
......
......@@ -92,4 +92,10 @@ $wb['pm_max_spare_servers_error_regex'] = 'PHP-FPM pm.max_spare_servers mu&szlig
$wb['hd_quota_error_regex'] = 'Harddisk Quota ist ungültig.';
$wb['traffic_quota_error_regex'] = 'Traffic Quota ist ungültig.';
$wb["fastcgi_php_version_txt"] = 'PHP-Version';
$wb["pm_txt"] = 'PHP-FPM Process Manager';
$wb["pm_process_idle_timeout_txt"] = 'PHP-FPM pm.process_idle_timeout';
$wb["pm_max_requests_txt"] = 'PHP-FPM pm.max_requests';
$wb["pm_process_idle_timeout_error_regex"] = 'PHP-FPM pm.process_idle_timeout muß eine positive ganze Zahl sein.';
$wb["pm_max_requests_error_regex"] = 'PHP-FPM pm.max_requests muß eine ganze Zahl >= 0 sein.';
$wb["pm_ondemand_hint_txt"] = 'Bitte beachten Sie, daß Ihre PHP-Version >= 5.3.9 sein muß, wenn Sie den ondemand Process-Manager nutzen möchten. Wenn Sie ondemand für eine ältere PHP-Version auswählen, wird PHP nicht mehr starten!';
?>
......@@ -92,4 +92,10 @@ $wb["pm_max_spare_servers_error_regex"] = 'PHP-FPM pm.max_spare_servers must be
$wb["hd_quota_error_regex"] = 'Harddisk quota is invalid.';
$wb["traffic_quota_error_regex"] = 'Traffic quota is invalid.';
$wb["fastcgi_php_version_txt"] = 'PHP Version';
$wb["pm_txt"] = 'PHP-FPM Process Manager';
$wb["pm_process_idle_timeout_txt"] = 'PHP-FPM pm.process_idle_timeout';
$wb["pm_max_requests_txt"] = 'PHP-FPM pm.max_requests';
$wb["pm_process_idle_timeout_error_regex"] = 'PHP-FPM pm.process_idle_timeout must be a positive integer value.';
$wb["pm_max_requests_error_regex"] = 'PHP-FPM pm.max_requests must be an integer value >= 0.';
$wb["pm_ondemand_hint_txt"] = 'Please note that you must have PHP version >= 5.3.9 in order to use the ondemand process manager. If you select ondemand for an older PHP version, PHP will not start anymore!';
?>
\ No newline at end of file
......@@ -20,28 +20,47 @@
<label for="allow_override">{tmpl_var name='allow_override_txt'}</label>
<input name="allow_override" id="allow_override" value="{tmpl_var name='allow_override'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder phpfpm">
<div class="phpfpm">
<div class="ctrlHolder">
<p class="label">{tmpl_var name='php_fpm_use_socket_txt'}</p>
<div class="multiField">
{tmpl_var name='php_fpm_use_socket'}
</div>
</div>
<div class="ctrlHolder phpfpm">
<div class="ctrlHolder">
<label for="pm">{tmpl_var name='pm_txt'}</label>
<select name="pm" id="pm" class="selectInput">
{tmpl_var name='pm'}
</select>
</div>
<div class="ctrlHolder pm_ondemand" style="background: #ffdfdf; border: 1px solid #df7d7d; border-width: 1px 0; margin: 1.5em 0 1.5em 0; padding: 7px;">
{tmpl_var name='pm_ondemand_hint_txt'}
</div>
<div class="ctrlHolder">
<label for="pm_max_children">{tmpl_var name='pm_max_children_txt'}</label>
<input name="pm_max_children" id="pm_max_children" value="{tmpl_var name='pm_max_children'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder phpfpm">
<div class="ctrlHolder pm_dynamic">
<label for="pm_start_servers">{tmpl_var name='pm_start_servers_txt'}</label>
<input name="pm_start_servers" id="pm_start_servers" value="{tmpl_var name='pm_start_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder phpfpm">
<div class="ctrlHolder pm_dynamic">
<label for="pm_min_spare_servers">{tmpl_var name='pm_min_spare_servers_txt'}</label>
<input name="pm_min_spare_servers" id="pm_min_spare_servers" value="{tmpl_var name='pm_min_spare_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder phpfpm">
<div class="ctrlHolder pm_dynamic">
<label for="pm_max_spare_servers">{tmpl_var name='pm_max_spare_servers_txt'}</label>
<input name="pm_max_spare_servers" id="pm_max_spare_servers" value="{tmpl_var name='pm_max_spare_servers'}" size="3" maxlength="3" type="text" class="textInput formLengthLimit" />
</div>
<div class="ctrlHolder pm_ondemand">
<label for="pm_process_idle_timeout">{tmpl_var name='pm_process_idle_timeout_txt'}</label>
<input name="pm_process_idle_timeout" id="pm_process_idle_timeout" value="{tmpl_var name='pm_process_idle_timeout'}" size="3" maxlength="6" type="text" class="textInput formLengthLimit" />&nbsp;s
</div>
<div class="ctrlHolder">
<label for="pm_max_requests">{tmpl_var name='pm_max_requests_txt'}</label>
<input name="pm_max_requests" id="pm_max_requests" value="{tmpl_var name='pm_max_requests'}" size="3" maxlength="6" type="text" class="textInput formLengthLimit" />
</div>
</div>
<div class="ctrlHolder">
<label for="php_open_basedir">{tmpl_var name='php_open_basedir_txt'}</label>
<input name="php_open_basedir" id="php_open_basedir" value="{tmpl_var name='php_open_basedir'}" size="30" type="text" class="textInput" style="width:400px;" />
......@@ -75,6 +94,30 @@
getServerId();
adjustForm();
var pm = jQuery('#pm').val();
pmMode(pm);
jQuery('#pm').change(function(){
pm = jQuery(this).val();
pmMode(pm);
});
function pmMode(pm){
switch(pm){
case "static":
jQuery('.pm_dynamic').add('.pm_ondemand').hide();
jQuery('.pm_static').show();
break;
case "dynamic":
jQuery('.pm_static').add('.pm_ondemand').hide();
jQuery('.pm_dynamic').show();
break;
case "ondemand":
jQuery('.pm_static').add('.pm_dynamic').hide();
jQuery('.pm_ondemand').show();
break;
}
}
function getServerId(){
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getserverid"}, function(data) {
serverId = data.serverid;
......
......@@ -518,7 +518,7 @@ class page_action extends tform_actions {
}
// Check if pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0
if(isset($this->dataRecord['pm_max_children'])) {
if(isset($this->dataRecord['pm_max_children']) && $this->dataRecord['pm'] == 'dynamic') {
if(intval($this->dataRecord['pm_max_children']) >= intval($this->dataRecord['pm_max_spare_servers']) && intval($this->dataRecord['pm_max_spare_servers']) >= intval($this->dataRecord['pm_start_servers']) && intval($this->dataRecord['pm_start_servers']) >= intval($this->dataRecord['pm_min_spare_servers']) && intval($this->dataRecord['pm_min_spare_servers']) > 0){
} else {
......
......@@ -14,11 +14,17 @@ listen.mode = 0660
user = <tmpl_var name='fpm_user'>
group = <tmpl_var name='fpm_group'>
pm = dynamic
pm = <tmpl_var name='pm'>
pm.max_children = <tmpl_var name='pm_max_children'>
<tmpl_if name='pm' op='==' value='dynamic'>
pm.start_servers = <tmpl_var name='pm_start_servers'>
pm.min_spare_servers = <tmpl_var name='pm_min_spare_servers'>
pm.max_spare_servers = <tmpl_var name='pm_max_spare_servers'>
</tmpl_if>
<tmpl_if name='pm' op='==' value='ondemand'>
pm.process_idle_timeout = <tmpl_var name='pm_process_idle_timeout'>s;
</tmpl_if>
pm.max_requests = <tmpl_var name='pm_max_requests'>
chdir = /
......
......@@ -2005,10 +2005,13 @@ class apache2_plugin {
$tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1);
$tpl->setVar('fpm_user', $data['new']['system_user']);
$tpl->setVar('fpm_group', $data['new']['system_group']);
$tpl->setVar('pm', $data['new']['pm']);
$tpl->setVar('pm_max_children', $data['new']['pm_max_children']);
$tpl->setVar('pm_start_servers', $data['new']['pm_start_servers']);
$tpl->setVar('pm_min_spare_servers', $data['new']['pm_min_spare_servers']);
$tpl->setVar('pm_max_spare_servers', $data['new']['pm_max_spare_servers']);
$tpl->setVar('pm_process_idle_timeout', $data['new']['pm_process_idle_timeout']);
$tpl->setVar('pm_max_requests', $data['new']['pm_max_requests']);
$tpl->setVar('document_root', $data['new']['document_root']);
$tpl->setVar('security_level',$web_config['security_level']);
$php_open_basedir = ($data['new']['php_open_basedir'] == '')?escapeshellcmd($data['new']['document_root']):escapeshellcmd($data['new']['php_open_basedir']);
......
......@@ -1630,10 +1630,13 @@ class nginx_plugin {
$tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1);
$tpl->setVar('fpm_user', $data['new']['system_user']);
$tpl->setVar('fpm_group', $data['new']['system_group']);
$tpl->setVar('pm', $data['new']['pm']);
$tpl->setVar('pm_max_children', $data['new']['pm_max_children']);
$tpl->setVar('pm_start_servers', $data['new']['pm_start_servers']);
$tpl->setVar('pm_min_spare_servers', $data['new']['pm_min_spare_servers']);
$tpl->setVar('pm_max_spare_servers', $data['new']['pm_max_spare_servers']);
$tpl->setVar('pm_process_idle_timeout', $data['new']['pm_process_idle_timeout']);
$tpl->setVar('pm_max_requests', $data['new']['pm_max_requests']);
$tpl->setVar('document_root', $data['new']['document_root']);
$tpl->setVar('security_level',$web_config['security_level']);
$php_open_basedir = ($data['new']['php_open_basedir'] == '')?escapeshellcmd($data['new']['document_root']):escapeshellcmd($data['new']['php_open_basedir']);
......
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