-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
37 lines (33 loc) · 1.13 KB
/
docker-entrypoint.sh
File metadata and controls
37 lines (33 loc) · 1.13 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
#!/bin/bash
set -e
# Define internal paths
export MOODLE_DOCKER_ROOT="/opt/moodle"
# Define if we are a worker/cron container
export IS_WORKER=false
if [[ "$1" == "cron" || "$1" == "worker" ]]; then
export IS_WORKER=true
fi
# Runner for modular entrypoint scripts
if [ -d "/docker-entrypoint.d" ]; then
echo "Running entrypoint scripts in /docker-entrypoint.d/..."
run-parts --verbose --exit-on-error --regex '.*\.sh$' /docker-entrypoint.d
fi
# Execution Phase
case "$1" in
cron|worker)
CRON_COUNT=${MOODLE_CRON_COUNT:-1}
ADHOC_COUNT=${MOODLE_ADHOC_TASK_COUNT:-0}
echo "Starting worker loop ($CRON_COUNT cron, $ADHOC_COUNT adhoc)..."
while true; do
for ((i=0; i<CRON_COUNT; i++)); do sudo -EHu www-data -- php /var/www/html/admin/cli/cron.php --keep-alive=59 & done
for ((i=0; i<ADHOC_COUNT; i++)); do sudo -EHu www-data -- php /var/www/html/admin/cli/adhoc_task.php --execute --keep-alive=59 & done
sleep 60
done
;;
php-fpm)
exec "$@"
;;
*)
if [ -z "$1" ]; then exec php-fpm; else exec php-fpm "$@"; fi
;;
esac