File 0009-Update-Apachectl-to-reference-cpanel.config-Addition.patch of Package ea-apache2

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cory McIntire <cory@cpanel.net>
Date: Thu, 12 Jul 2018 15:41:19 -0500
Subject: [PATCH 09/21] Update Apachectl to reference cpanel.config;
 Additionally allow MIN_FD_LIMIT and MAX_FD_LIMIT to be configurable

---
 support/apachectl.in | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/support/apachectl.in b/support/apachectl.in
index c6ac3ea..07c9912 100644
--- a/support/apachectl.in
+++ b/support/apachectl.in
@@ -56,7 +56,8 @@ fi
 #
 # the URL to your server's mod_status status page.  If you do not
 # have one, then status and fullstatus will not work.
-STATUSURL="http://localhost:@PORT@/server-status"
+PORT="$(grep 'apache_port=' /var/cpanel/cpanel.config 2>/dev/null | sed -e 's/.*=\([.0-9]*:\)\{0,1\}//;' -e 's/[^0-9]*//g' 2>/dev/null)"
+STATUSURL="http://localhost:${PORT:-80}/whm-server-status"
 
 # Source /etc/sysconfig/httpd for $HTTPD setting, etc.
 if [ -r /etc/sysconfig/httpd ]; then
@@ -68,7 +69,22 @@ fi
 # number of file descriptors allowed per child process. This is
 # critical for configurations that use many file descriptors,
 # such as mass vhosting, or a multithreaded server.
-ULIMIT_MAX_FILES="@APACHECTL_ULIMIT@"
+
+# Can be overwritten by setting MIN_FD_LIMIT and MAX_FD_LIMIT in /etc/sysconfig/httpd
+if [ -z "$MIN_FD_LIMIT" ]; then
+    MIN_FD_LIMIT=1024
+fi
+
+if [ -z "$MAX_FD_LIMIT" ]; then
+    MAX_FD_LIMIT=16384
+fi
+
+while [ $MIN_FD_LIMIT -le $MAX_FD_LIMIT ]; do
+    ulimit -H -n $MIN_FD_LIMIT 2>/dev/null
+    ulimit -S -n $MIN_FD_LIMIT 2>/dev/null
+    MIN_FD_LIMIT=$(($MIN_FD_LIMIT * 2))
+done
+
 # --------------------                              --------------------
 # ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||
 
openSUSE Build Service is sponsored by