summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xacid/cyche-remove20
-rwxr-xr-xacid/cychedelic12
2 files changed, 32 insertions, 0 deletions
diff --git a/acid/cyche-remove b/acid/cyche-remove
new file mode 100755
index 0000000..1aa5f36
--- /dev/null
+++ b/acid/cyche-remove
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# cyche-remove <name>
+#
+# Stop the service <name>, which was previously managed by cychedelic, and
+# remove associated files.
+
+cd "/services/$1"
+
+file=$(cat '.git/previous_file')
+slug=$(cat '.git/previous_slug')
+[ -n "$slug" ] && slug="--project-name $slug"
+
+docker compose $slug --file "$file" down \
+ --remove-orphans
+
+echo "Removing files..."
+cd ".."
+rm -rf "$1"
+echo "Done."
diff --git a/acid/cychedelic b/acid/cychedelic
index 17f2d33..a73554a 100755
--- a/acid/cychedelic
+++ b/acid/cychedelic
@@ -37,11 +37,23 @@ update() {
done
}
+remove() {
+ next=$(printf '%s\n' "${CYCHE_SERVICES[@]}" | awk '{print $1}')
+ prev=$(ls -A '/services')
+ removed=$(printf '%s\n' "$next" "$next" "$prev" | sort | uniq -u)
+
+ for name in $removed; do
+ cyche-remove "$name"
+ sleep "$CYCHE_JOB_TIME"
+ 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"
+remove
update --force
docker system prune --force --all
starttime=$(now)