Make php-fpm's max_children configurable
This commit is contained in:
parent
afa5791d07
commit
eb6b05c9db
3 changed files with 14 additions and 9 deletions
|
|
@ -93,7 +93,7 @@ impl<'b, C: 'b + CommandRunner, P: 'b + Policy> SymbolFactory<'b, C, P> {
|
|||
format!("/run/php/{}.sock", user_name).into()
|
||||
}
|
||||
|
||||
fn get_php_fpm_pool<'a>(&'a self, user_name: &str) -> impl Symbol + 'a {
|
||||
fn get_php_fpm_pool<'a>(&'a self, user_name: &str, max_children: usize) -> impl Symbol + 'a {
|
||||
let socket = self.get_php_fpm_pool_socket_path(user_name);
|
||||
let php_version = self.policy.php_version();
|
||||
Hook::new(
|
||||
|
|
@ -107,12 +107,13 @@ group = www-data
|
|||
listen = {1}
|
||||
listen.owner = www-data
|
||||
pm = ondemand
|
||||
pm.max_children = 10
|
||||
pm.max_children = {2}
|
||||
catch_workers_output = yes
|
||||
env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
",
|
||||
user_name,
|
||||
socket.to_str().unwrap()
|
||||
socket.to_str().unwrap(),
|
||||
max_children
|
||||
),
|
||||
),
|
||||
ReloadService::new(format!("php{}-fpm", php_version), self.command_runner),
|
||||
|
|
@ -123,12 +124,13 @@ env[PATH] = /usr/local/bin:/usr/bin:/bin
|
|||
&'a self,
|
||||
host_name: &'static str,
|
||||
root_dir: ROOT,
|
||||
max_children: usize,
|
||||
additional_config: &'a str,
|
||||
) -> impl Symbol + 'a {
|
||||
let user_name = self.policy.user_name_for_host(host_name);
|
||||
let socket = self.get_php_fpm_pool_socket_path(&user_name);
|
||||
List::from((
|
||||
self.get_php_fpm_pool(&user_name),
|
||||
self.get_php_fpm_pool(&user_name, max_children),
|
||||
self.get_nginx_acme_server(
|
||||
host_name,
|
||||
NginxServer::new_php(
|
||||
|
|
@ -150,6 +152,7 @@ env[PATH] = /usr/local/bin:/usr/bin:/bin
|
|||
self.serve_php(
|
||||
host_name,
|
||||
root_dir,
|
||||
10,
|
||||
"
|
||||
location / {{
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
|
|
@ -166,7 +169,7 @@ env[PATH] = /usr/local/bin:/usr/bin:/bin
|
|||
let user_name = self.policy.user_name_for_host(host_name);
|
||||
let socket = self.get_php_fpm_pool_socket_path(&user_name);
|
||||
List::from((
|
||||
self.get_php_fpm_pool(&user_name),
|
||||
self.get_php_fpm_pool(&user_name, 10),
|
||||
self.get_nginx_acme_server(host_name,
|
||||
NginxServer::new(
|
||||
host_name,
|
||||
|
|
@ -205,6 +208,7 @@ env[PATH] = /usr/local/bin:/usr/bin:/bin
|
|||
self.serve_php(
|
||||
host_name,
|
||||
root_dir,
|
||||
25,
|
||||
"
|
||||
client_max_body_size 500M;
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ impl<'a, C: CommandRunner> NginxServer<'a, C, String, PathBuf> {
|
|||
|
||||
pub fn new_proxy<S: SocketSpec, STATIC: AsRef<Path>>(
|
||||
domain: &'a str,
|
||||
socket_path: &'_ S,
|
||||
socket_path: &S,
|
||||
static_path: STATIC,
|
||||
command_runner: &'a C,
|
||||
) -> Self {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,10 @@ impl<S: AsRef<str>, C: CommandRunner> Symbol for ReloadService<'_, S, C> {
|
|||
}
|
||||
|
||||
fn execute(&self) -> Result<(), Box<dyn Error>> {
|
||||
self
|
||||
.command_runner
|
||||
.run_successfully("systemctl", args!["reload-or-restart", self.service.as_ref()])
|
||||
self.command_runner.run_successfully(
|
||||
"systemctl",
|
||||
args!["reload-or-restart", self.service.as_ref()],
|
||||
)
|
||||
}
|
||||
|
||||
fn as_action<'b>(&'b self, runner: &'b dyn SymbolRunner) -> Box<dyn Action + 'b> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue