veza/tmt/tests/backend/memory_budget.sh
senke ad60247f33 feat: global update including storybook setup and backend fixes
- Web: Setup Storybook, added addons, configured Tailwind, added stories for UI components.
- Backend: Updated API router, database, workers, and auth in common.
- Stream Server: Removed SQLx queries and updated auth.
- Docs & Scripts: Updated documentation and recovery scripts.
2026-02-02 19:34:14 +01:00

39 lines
853 B
Bash
Executable file

#!/bin/bash
set -e
# CONTRACT: docs/BUDGETS.md
# DO NOT CHANGE THESE VALUES WITHOUT UPDATING THE CONTRACT FIRST.
MAX_RSS_MB=100
REPO_ROOT=$(git rev-parse --show-toplevel)
BACKEND_DIR="$REPO_ROOT/veza-backend-api"
echo "📍 Backend Memory Budget Check"
echo "📜 Contract: docs/BUDGETS.md"
echo "🧠 Budget: ${MAX_RSS_MB}MB RSS (Idle)"
cd "$BACKEND_DIR"
go build -o server_mem_check ./cmd/modern-server/main.go
# Start
./server_mem_check > /dev/null 2>&1 &
PID=$!
sleep 2
# Measure RSS
RSS_KB=$(ps -o rss= -p $PID | awk '{print $1}')
RSS_MB=$((RSS_KB / 1024))
echo "📊 Current RSS: ${RSS_MB}MB"
kill $PID
rm -f server_mem_check
if [ "$RSS_MB" -gt "$MAX_RSS_MB" ]; then
echo "❌ FATAL: Memory budget exceeded!"
echo " Limit: ${MAX_RSS_MB}MB"
echo " Actual: ${RSS_MB}MB"
exit 1
fi
echo "✅ Memory usage within budget."