Repository navigation
Expand file tree
/
Copy pathdocker-go-entrypoint.sh
More file actions
executable file
·63 lines (53 loc) · 2.45 KB
/
Copy pathdocker-go-entrypoint.sh
File metadata and controls
executable file
·63 lines (53 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
set -e
if [ ! -d /etc/groupoffice/multi_instance ]; then
mkdir -p /etc/groupoffice/multi_instance && chown -R www-data:www-data /etc/groupoffice
fi
if [ ! -d /var/lib/groupoffice/multi_instance ]; then
mkdir -p /var/lib/groupoffice/multi_instance && chown -R www-data:www-data /var/lib/groupoffice
fi
if [ ! -f /etc/groupoffice/config.php ]; then
cp /usr/local/share/groupoffice-config.php /etc/groupoffice/config.php
fi
cp /usr/local/share/groupoffice-docker-config.php.tpl /etc/groupoffice/docker-config.php
sed -i 's/{dbHost}/'${MYSQL_HOST}'/' /etc/groupoffice/docker-config.php
sed -i 's/{dbName}/'${MYSQL_DATABASE}'/' /etc/groupoffice/docker-config.php
sed -i 's/{dbUser}/'${MYSQL_USER}'/' /etc/groupoffice/docker-config.php
sed -i 's/{dbPass}/'${MYSQL_PASSWORD}'/' /etc/groupoffice/docker-config.php
# Size Apache prefork workers to the container memory. Every worker is a full PHP process and
# long-lived requests (SSE, ActiveSync ping) each hold one, so the Debian default of 150 is often wrong.
# Override with APACHE_MAX_REQUEST_WORKERS or tune the estimate with APACHE_WORKER_MEMORY (MB per worker).
if [ -z "$APACHE_MAX_REQUEST_WORKERS" ]; then
mem_bytes=""
if [ -r /sys/fs/cgroup/memory.max ]; then
mem_bytes=$(cat /sys/fs/cgroup/memory.max)
elif [ -r /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
mem_bytes=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
fi
host_bytes=$(( $(awk '/^MemTotal:/ {print $2}' /proc/meminfo) * 1024 ))
# "max" or a huge cgroup v1 value means no limit was set
case "$mem_bytes" in
''|*[!0-9]*) mem_bytes=$host_bytes ;;
esac
if [ "$mem_bytes" -gt "$host_bytes" ]; then
mem_bytes=$host_bytes
fi
# reserve 256MB for the OS, Apache parent, opcache and APCu shared memory
mem_mb=$(( mem_bytes / 1024 / 1024 - 256 ))
APACHE_MAX_REQUEST_WORKERS=$(( mem_mb / ${APACHE_WORKER_MEMORY:-50} ))
if [ "$APACHE_MAX_REQUEST_WORKERS" -lt 10 ]; then
APACHE_MAX_REQUEST_WORKERS=10
elif [ "$APACHE_MAX_REQUEST_WORKERS" -gt 1000 ]; then
APACHE_MAX_REQUEST_WORKERS=1000
fi
fi
cat > /etc/apache2/conf-enabled/zz-groupoffice-mpm.conf <<EOF
# Generated by docker-go-entrypoint.sh
<IfModule mpm_prefork_module>
ServerLimit $APACHE_MAX_REQUEST_WORKERS
MaxRequestWorkers $APACHE_MAX_REQUEST_WORKERS
</IfModule>
EOF
echo "Apache MaxRequestWorkers set to $APACHE_MAX_REQUEST_WORKERS"
#call original entry point
docker-php-entrypoint "$@"