Skip to content

Commit ebf59d0

Browse files
committed
Add scheduled task, default to run every 10 min.
1 parent 66a7e61 commit ebf59d0

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,5 @@ ASALocalRun/
340340
healthchecksdb
341341

342342
infra.params.json
343+
.env
344+
*.params.json

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ FROM litespeedtech/openlitespeed:$OLS_VERSION-$PHP_VERSION
44

55
#install SSH
66
RUN set -ex; \
7-
apt-get update; \
7+
apt-get update; \
88
apt-get install -y --no-install-recommends \
9+
unzip \
910
openssh-server; \
10-
rm -rf /var/lib/apt/lists/*
11+
rm -rf /var/lib/apt/lists/*
1112

1213
RUN set -ex; \
1314
echo "root:Docker!" | chpasswd; \

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ None.
1717
| OpenLiteSpeed | 1.6.18 |
1818
| PHP | 7.4 |
1919

20-
SSH has been enabled on port 2222 to be able to SSH to the container in Azure App Service.
20+
* SSH has been enabled on port 2222 to be able to SSH to the container in Azure App Service.
21+
* A cron/scheduled task is setup to run `/home/site/cron.sh`, if it exists, every 10 minutes. Set `PHP_CRON` environment variable to a valid [cron formated](https://en.wikipedia.org/wiki/Cron) schedule to change from the default execute interval. The last `cron.sh` task run is logged to `/home/site/cron.log`
2122

2223
## Deployment
2324

php-entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ PHP version : `php -v | head -n 1 | cut -d ' ' -f 2`
1313
EOL
1414
cat /etc/motd
1515

16+
if [ -z ${PHP_CRON+x} ]; then
17+
export PHP_CRON='*/10 * * * *'
18+
fi
19+
20+
cat >/etc/cron.d/phpcron <<EOL
21+
${PHP_CRON} root cd /home/site/; if [ -e cron.sh ]; then /home/site/cron.sh > /home/site/cron.log 2>&1; fi; date > /home/site/cron-last-run
22+
EOL
23+
chmod 600 /etc/cron.d/php
24+
chmod 600 /etc/cron.d/phpcron
25+
1626
service ssh start
27+
service cron start
1728

1829
exec "$@"

0 commit comments

Comments
 (0)