diff options
Diffstat (limited to 'satellit_installer/static_files/lighttpd/usr/local/sbin/patch_lighttpd_phpchildren')
-rwxr-xr-x | satellit_installer/static_files/lighttpd/usr/local/sbin/patch_lighttpd_phpchildren | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/satellit_installer/static_files/lighttpd/usr/local/sbin/patch_lighttpd_phpchildren b/satellit_installer/static_files/lighttpd/usr/local/sbin/patch_lighttpd_phpchildren new file mode 100755 index 0000000..a8e44e5 --- /dev/null +++ b/satellit_installer/static_files/lighttpd/usr/local/sbin/patch_lighttpd_phpchildren @@ -0,0 +1,23 @@ +#!/bin/sh + +# Could be written in one line, but for better editing when values change... +MEM=$(grep ^MemTotal /proc/meminfo | awk '{print $2}') # RAM in KB +MEM=$(( MEM / 1024 / 4 )) # to MB, and assess a fourth of RAM for PHP +CHILDREN=$(( MEM / 16 )) # assume 16 MB per child +# min 16, no more than 128 (inverse logic to handle NaN) +[ "$CHILDREN" -ge 16 ] || CHILDREN=16 +[ "$CHILDREN" -le 128 ] || CHILDREN=128 + +## Use ?? in case the ordering changes one day +file=$(echo /etc/lighttpd/conf-enabled/??-fastcgi-php.conf) +if [ -f "$file" ]; then + sed -i 's/"PHP_FCGI_CHILDREN.*$/"PHP_FCGI_CHILDREN" => "'$CHILDREN'",/' "$file" + if ! grep -qF '"PHP_FCGI_CHILDREN" => "'$CHILDREN'"' "$file"; then + echo "WARNING: Cannot adjust php cgildren count for fastcgi -- line not found in $file" >&2 + fi +else + echo "WARNING: Cannot adjust php children count for fastcgi -- file not found" >&2 + exit 1 +fi +exit 0 + |