Skip to content

Commit 996cb0e

Browse files
committed
Use new API to get and set FPM config values
1 parent 69f46ca commit 996cb0e

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

virtual_feature.pl

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,15 +1497,8 @@ sub feature_get_web_php_children
14971497
# Read from FPM config file
14981498
my $conf = &virtual_server::get_php_fpm_config();
14991499
return -1 if (!$conf);
1500-
my $file = $conf->{'dir'}."/".$d->{'id'}.".conf";
1501-
my $lref = &read_file_lines($file, 1);
1502-
my $childs = 0;
1503-
foreach my $l (@$lref) {
1504-
if ($l =~ /pm.max_children\s*=\s*(\d+)/) {
1505-
$childs = $1;
1506-
}
1507-
}
1508-
&unflush_file_lines($file);
1500+
my $childs = &virtual_server::get_php_fpm_pool_config_value(
1501+
$conf, $d->{'id'}, "pm.max_children");
15091502
return $childs == $childrenmax ? 0 : $childs;
15101503
}
15111504
else {
@@ -1535,20 +1528,9 @@ sub feature_save_web_php_children
15351528
# Set in the FPM config
15361529
my $conf = &virtual_server::get_php_fpm_config();
15371530
return 0 if (!$conf);
1538-
my $file = $conf->{'dir'}."/".$d->{'id'}.".conf";
1539-
return 0 if (!-r $file);
1540-
&lock_file($file);
1541-
my $lref = &read_file_lines($file);
15421531
$children = $childrenmax if ($children == 0); # Recommended default
1543-
foreach my $l (@$lref) {
1544-
if ($l =~ /pm.max_children\s*=\s*(\d+)/) {
1545-
$l = "pm.max_children = $children";
1546-
}
1547-
}
1548-
&flush_file_lines($file);
1549-
&unlock_file($file);
1550-
&virtual_server::register_post_action(
1551-
\&virtual_server::restart_php_fpm_server);
1532+
&save_php_fpm_pool_config_value(
1533+
$conf, $d->{'id'}, "pm.max_children", $children);
15521534
}
15531535
&virtual_server::save_domain($d);
15541536
}

0 commit comments

Comments
 (0)