diff options
Diffstat (limited to 'acid')
-rwxr-xr-x | acid/cychedelic | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/acid/cychedelic b/acid/cychedelic new file mode 100755 index 0000000..002fb98 --- /dev/null +++ b/acid/cychedelic @@ -0,0 +1,52 @@ +#!/bin/bash + +# cychedelic ACID daemon +# cychedelic is an automated Continuous Deployment solution. See the README for +# more information. + +source config.sh + +now() { + date '+%s' +} + +should_restart() { + curtime=$(now) + runtime=$((curtime-starttime)) + [ $runtime -gt $CYCHE_MAINT_TIME ] +} + +update() { + forceopt="--force-self" + selfopt="--self" + + for line in "${CYCHE_SERVICES[@]}"; do + hash=$(cyche-source $line) + + if [ $? -ne 0 ] || [ "$1" == "$forceopt" ]; then + read -r -a arr <<< "$line" + cyche-build "${arr[0]}" "$hash" $selfopt + fi + + forceopt="--force" + selfopt="" + done +} + +# startup: A restart of the ACID daemon usually indicates an elapse of the +# $CYCHE_MAINT_TIME period, so rebuild services and perform cleanup now. We +# sleep briefly at the beginning to allow the previous cychedelic instance time +# to die. +sleep "$CYCHE_STARTUP_TIME" +update --force +docker system prune --force --all +starttime=$(now) + +# monitor source changes +while ! should_restart; do + sleep "$CYCHE_POLL_TIME" + update +done + +# force self-upgrade to trigger maintenance activities +update --force-self |