fix/docker-log-rotation-disk-management (#93)
Co-authored-by: openhands <openhands@all-hands.dev> Reviewed-on: https://codeberg.org/johba/harb/pulls/93
This commit is contained in:
parent
5d71753086
commit
19bac420d0
4 changed files with 78 additions and 1 deletions
55
scripts/cleanup-disk.sh
Executable file
55
scripts/cleanup-disk.sh
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Disk cleanup utility for Harb stack
|
||||
# Use this to aggressively free up disk space
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
echo "=== Harb Stack Disk Cleanup ==="
|
||||
echo ""
|
||||
|
||||
# Detect container runtime
|
||||
if command -v docker &> /dev/null; then
|
||||
RUNTIME_CMD="docker"
|
||||
elif command -v podman &> /dev/null; then
|
||||
RUNTIME_CMD="podman"
|
||||
else
|
||||
echo "Error: docker/podman not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Current disk usage:"
|
||||
df -h / | tail -1
|
||||
echo ""
|
||||
|
||||
# Stop the stack first
|
||||
if [[ -f "./scripts/dev.sh" ]]; then
|
||||
echo "Stopping stack..."
|
||||
./scripts/dev.sh stop || true
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Pruning Docker resources..."
|
||||
echo " - Stopped containers"
|
||||
echo " - Unused volumes"
|
||||
echo " - Dangling images"
|
||||
echo " - Build cache"
|
||||
echo ""
|
||||
|
||||
# Aggressive pruning
|
||||
${RUNTIME_CMD} system prune -af --volumes
|
||||
|
||||
echo ""
|
||||
echo "Cleaning npm caches..."
|
||||
rm -rf ~/.npm ~/.cache 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "Cleaning journal logs..."
|
||||
sudo journalctl --vacuum-size=500M 2>/dev/null || echo " (skipped: needs sudo)"
|
||||
|
||||
echo ""
|
||||
echo "Final disk usage:"
|
||||
df -h / | tail -1
|
||||
echo ""
|
||||
echo "[ok] Cleanup complete"
|
||||
|
|
@ -162,7 +162,12 @@ start_stack() {
|
|||
stop_stack() {
|
||||
cleanup_existing
|
||||
${COMPOSE_CMD} down
|
||||
echo "[ok] Stack stopped"
|
||||
|
||||
# Prune Docker resources to prevent disk bloat
|
||||
echo " Pruning Docker resources..."
|
||||
${RUNTIME_CMD} system prune -f --volumes 2>&1 | grep -E "Total reclaimed|deleted" || true
|
||||
|
||||
echo "[ok] Stack stopped and cleaned"
|
||||
}
|
||||
|
||||
check_health() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue