Skip to content

Commit b71046f

Browse files
committed
backport s6 to 83-moodle-unit #101
1 parent 847ae38 commit b71046f

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

php83-moodle-unit/Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
FROM alpine:edge
22

3-
ENV COMPOSER_HASH dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6
3+
ENV COMPOSER_HASH=dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6
44

5-
ENV PHPRUN_DEPS \
6-
curl \
5+
ENV PHPRUN_DEPS="curl \
76
git \
87
libxml2-utils \
98
libxslt \
@@ -13,8 +12,9 @@ ENV PHPRUN_DEPS \
1312
openssh-client \
1413
patch \
1514
rsync \
15+
s6-overlay \
1616
sqlite \
17-
wget
17+
wget"
1818

1919
RUN set -e \
2020
&& apk --update upgrade \
@@ -81,8 +81,13 @@ COPY conf.json /var/lib/unit/
8181

8282
COPY xx-moodle.ini /etc/php83/conf.d/xx-moodle.ini
8383

84+
COPY cron.sh /usr/local/bin/cron.sh
85+
COPY crontab /etc/crontabs/root
86+
87+
COPY services /etc/services.d/
88+
8489
WORKDIR /var/www/html
8590

8691
EXPOSE 80
8792

88-
CMD ["unitd", "--no-daemon", "--user", "web-user", "--group", "web-group", "--log", "/dev/stdout"]
93+
ENTRYPOINT ["/init"]

php83-moodle-unit/cron.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
reduce_cron_verbosity() {
4+
while IFS= read -r line; do
5+
case "$line" in
6+
*"Continuing to check for tasks for"*) ;;
7+
"Ran 0 adhoc tasks found"*) ;;
8+
"Cron run completed correctly"*) ;;
9+
"..."*) ;;
10+
"") ;;
11+
*) echo "$(date +"%Y/%m/%d %H:%M:%S") [cron] $line" ;;
12+
esac
13+
done
14+
}
15+
16+
if [ -f /var/www/html/web/admin/cli/cron.php ]; then
17+
echo "$(date +"%Y/%m/%d %H:%M:%S") [cron] Cron execution started" 1>&2
18+
php /var/www/html/web/admin/cli/cron.php | reduce_cron_verbosity 1>&2
19+
echo "$(date +"%Y/%m/%d %H:%M:%S") [cron] Cron execution finished" 1>&2
20+
else
21+
echo "$(date +"%Y/%m/%d %H:%M:%S") [cron] Moodle cron script not found" 1>&2
22+
fi

php83-moodle-unit/crontab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* * * * * /usr/local/bin/cron.sh >> /dev/stdout 2>&1

php83-moodle-unit/services/cron/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
exec crond -f 2>&1

php83-moodle-unit/services/unit/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
exec unitd --no-daemon --user web-user --group web-group --log /dev/stdout

0 commit comments

Comments
 (0)