mirror of
https://github.com/zokradonh/kopano-docker.git
synced 2026-08-22 22:03:03 +00:00
wip: Implement a scheduler to run recurring tasks (such as z-push-gabsync) (#123)
* add scheduler container for gabsync Adds a general scheduler container to trigger tasks within containers. Also adds gabsync to zpush image * make scheduler dynamic execute each cron job once at startup to see if they would succeed * remove services scripts from core container (now is part of the scheduler) * add "CRONDELAY" for tasks that should not be executed at startup * add documentation * clear out crontab at startup
This commit is contained in:
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
cronfile=/etc/crontab
|
||||
|
||||
# purge existing entries from crontab
|
||||
true > "$cronfile"
|
||||
|
||||
for cronvar in ${!CRON_*}; do
|
||||
cronvalue=${!cronvar}
|
||||
echo "Adding $cronvalue to crontab"
|
||||
echo "$cronvalue" >> "$cronfile"
|
||||
done
|
||||
|
||||
for cronvar in ${!CRONDELAYED_*}; do
|
||||
cronvalue=${!cronvar}
|
||||
echo "Adding $cronvalue to crontab"
|
||||
echo "$cronvalue" >> "$cronfile"
|
||||
done
|
||||
|
||||
# wait for kopano_server statup to run one-off commands
|
||||
dockerize \
|
||||
-wait tcp://kopano_server:236 \
|
||||
-timeout 360s
|
||||
echo "creating public store"
|
||||
docker exec kopano_server kopano-storeadm -h default: -P || true
|
||||
|
||||
# run sheduled cron jobs once
|
||||
for cronvar in ${!CRON_*}; do
|
||||
cronvalue=${!cronvar}
|
||||
croncommand=$(echo "$cronvalue" | cut -d ' ' -f 6-)
|
||||
echo "Running: $croncommand"
|
||||
$croncommand
|
||||
done
|
||||
|
||||
exec supercronic /etc/crontab
|
||||
Reference in New Issue
Block a user