From d73599ffd979c39d76389d9e00d02b05ccba4777 Mon Sep 17 00:00:00 2001
From: Lars Beckers <lars.beckers@rwth-aachen.de>
Date: Wed, 17 Jul 2019 16:48:13 +0200
Subject: [PATCH] allow configuring php-fpm process manager

---
 php-fpm/templates/pool.conf.j2 | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/php-fpm/templates/pool.conf.j2 b/php-fpm/templates/pool.conf.j2
index 05468ff..2980888 100644
--- a/php-fpm/templates/pool.conf.j2
+++ b/php-fpm/templates/pool.conf.j2
@@ -10,10 +10,20 @@ listen = /run/php/{{item.name}}-fpm.sock
 listen.owner = {{item.socket_user}}
 listen.group = {{item.socket_group}}
 
-pm = ondemand
-pm.max_children = 10
-pm.process_idle_timeout = 10s
-pm.max_requests = 500
+pm = {{ item.pm|default('ondemand') }}
+{% if item.pm|default('ondemand') == 'static' %}
+pm.max_children = {{ item.pm_max_children|default(5) }}
+{% elif item.pm|default('ondemand') == 'dynamic' %}
+pm.max_children = {{ item.pm_max_children|default(5) }}
+{# start_servers = min_spare_servers + (max_spare_servers - min_spare_servers) / 2 #}
+pm.start_servers = {{ item.pm_start_servers|default(2) }}
+pm.min_spare_servers = {{ item.pm_min_spare_servers|default(1) }}
+pm.max_spare_servers = {{ item.pm_max_spare_servers|default(3) }}
+{% else %}
+pm.max_children = {{ item.pm_max_children|default(10) }}
+pm.process_idle_timeout = {{ item.pm_process_idle_timeout|default(15) }}s
+{% endif %}
+pm.max_requests = {{ item.pm_max_requests|default(500) }}
 
 {% if item.params is defined and item.params %}
 {% for key, value in item.params.items() %}
-- 
GitLab