diff --git a/backend-services/scripts/restart.sh b/backend-services/scripts/restart.sh new file mode 100644 index 00000000..d912a9e8 --- /dev/null +++ b/backend-services/scripts/restart.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +#CHANGE ME +compose_file="/path/to/compose/file" + +# Threshold in MB (8 GB = 8192 MB) +threshold=8980 + +# Get total memory usage in MB +used=$(free -m | awk '/^Mem:/ {print $3}') + +if [ "$USED" -ge "$THRESHOLD" ]; then + echo "Memory usage is ${used}MB (≥ ${threshold}MB). Restarting Invidious..." + docker compose -f "$compose_file" down >/dev/null 2>&1 + docker compose -f "$compose_file" up -d >/dev/null 2>&1 +else + echo "Memory usage is ${used}MB (< ${threshold}MB). No restart performed." +fi