Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ebpf-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MAX_LOG_SIZE=${MAX_LOG_SIZE:-10485760} # Default to 10 MB if not set (10 MB = 1
CHECK_INTERVAL=${CHECK_INTERVAL:-60}
CHECK_INTERVAL_MEM=${CHECK_INTERVAL_MEM:-10} # Check interval in seconds (configurable via env)
MEMORY_THRESHOLD=${MEMORY_THRESHOLD:-80} # Kill process at this % memory usage (configurable via env)
GOMEMLIMIT_PERCENT=${GOMEMLIMIT_PERCENT:-60} # GOMEMLIMIT as % of container memory limit (configurable via env)

# Function to rotate the log file
rotate_log() {
Expand Down Expand Up @@ -83,11 +84,12 @@ fi

echo "Using container memory limit: ${MEM_LIMIT_MB} MB"

# Set GOMEMLIMIT for the Go process
GOMEMLIMIT_MB=$((MEM_LIMIT_MB * GOMEMLIMIT_PERCENT / 100))
export GOMEMLIMIT="${GOMEMLIMIT_MB}MiB"
echo "Setting GOMEMLIMIT to: ${GOMEMLIMIT} (${GOMEMLIMIT_PERCENT}% of ${MEM_LIMIT_MB} MB)"

# Start memory monitoring in the background
while true; do
check_memory_and_kill
sleep "$CHECK_INTERVAL_MEM"
done &

while :
do
Expand Down
Loading