Bug 17610 - Allow the number of plack workers and max connections to be set in koha...
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 10 Nov 2016 19:53:30 +0000 (19:53 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Tue, 31 Jan 2017 17:20:31 +0000 (17:20 +0000)
It would be nice if we could control the number of workers and max
requests on a per instance basis, rather than the numbers being
hardcoded in the plack startup script.

Test Plan:
1) Build a new package of Koha with this patch applied ; )
2) Verify koha-plack still works
3) Add the following to the config section of your koha-conf.xml:
 <plack_max_requests>75</plack_max_requests>
 <plack_workers>4</plack_workers>
4) Stop plack
5) Start plack
6) Verify the number of works and max requests worked!

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Larry Baerveldt <larry@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Rebased against master and added a description for the new configuration
entries

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

debian/scripts/koha-plack
debian/templates/koha-conf-site.xml.in
etc/koha-conf.xml

index 9d0a6c5..245d4a5 100755 (executable)
@@ -74,7 +74,18 @@ start_plack()
 
     _check_and_fix_perms $instancename
 
-    STARMANOPTS="-M FindBin --max-requests 50 --workers 2 \
+    PLACK_MAX_REQUESTS="50"
+    PLACK_WORKERS="2"
+
+    if [[ $(get_plack_max_requests $instancename) ]]; then
+        PLACK_MAX_REQUESTS="$(get_plack_max_requests $instancename)"
+    fi
+
+    if [[ $(get_plack_workers $instancename) ]]; then
+        PLACK_WORKERS="$(get_plack_workers $instancename)"
+    fi
+
+    STARMANOPTS="-M FindBin --max-requests ${PLACK_MAX_REQUESTS} --workers ${PLACK_WORKERS} \
                  --user=${instancename}-koha --group ${instancename}-koha \
                  --pid ${PIDFILE} \
                  --daemonize \
@@ -247,6 +258,14 @@ adjust_paths()
     fi
 }
 
+get_plack_max_requests() {
+    xmlstarlet sel -t -v 'yazgfs/config/plack_max_requests' "/etc/koha/sites/$1/koha-conf.xml"
+}
+
+get_plack_workers() {
+    xmlstarlet sel -t -v 'yazgfs/config/plack_workers' "/etc/koha/sites/$1/koha-conf.xml"
+}
+
 STARMAN=$(which starman)
 op=""
 quiet="no"
index 47cce8d..2add4aa 100644 (file)
@@ -317,5 +317,10 @@ __END_SRU_PUBLICSERVER__
 
  <!-- Path to the config file for SMS::Send -->
  <sms_send_config>__KOHA_CONF_DIR__/sms_send/</sms_send_config>
+
+ <!-- Configuration for Plack -->
+ <plack_max_requests>50</plack_max_requests>
+ <plack_workers>2</plack_workers>
+
 </config>
 </yazgfs>
index 650b0f8..1e5c799 100644 (file)
@@ -143,6 +143,11 @@ __PAZPAR2_TOGGLE_XML_POST__
  </ttf>
 
  <!-- Path to the config file for SMS::Send -->
-  <sms_send_config>__KOHA_CONF_DIR__/sms_send/</sms_send_config>
+ <sms_send_config>__KOHA_CONF_DIR__/sms_send/</sms_send_config>
+
+ <!-- Configuration for Plack -->
+ <plack_max_requests>50</plack_max_requests>
+ <plack_workers>2</plack_workers>
+
 </config>
 </yazgfs>