diff options
author | Malfurious <m@lfurio.us> | 2023-08-09 06:31:14 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2023-08-09 06:31:14 -0400 |
commit | f82863941f2a2835898dbb7bc47d27c2e783b744 (patch) | |
tree | e6455dee1ce7bd73f8ae357ae99c3a1027a926e9 | |
parent | e35da6fc7bf4c3ca554c534e2b72922c7bfe1bed (diff) | |
download | cychedelic-f82863941f2a2835898dbb7bc47d27c2e783b744.tar.gz cychedelic-f82863941f2a2835898dbb7bc47d27c2e783b744.zip |
acid: Add entrypoint script
Signed-off-by: Malfurious <m@lfurio.us>
-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 |