File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ MAX_LOG_SIZE=${MAX_LOG_SIZE:-10485760} # Default to 10 MB if not set (10 MB = 1
55CHECK_INTERVAL=${CHECK_INTERVAL:- 60}
66CHECK_INTERVAL_MEM=${CHECK_INTERVAL_MEM:- 10} # Check interval in seconds (configurable via env)
77MEMORY_THRESHOLD=${MEMORY_THRESHOLD:- 80} # Kill process at this % memory usage (configurable via env)
8+ GOMEMLIMIT_PERCENT=${GOMEMLIMIT_PERCENT:- 60} # GOMEMLIMIT as % of container memory limit (configurable via env)
89
910# Function to rotate the log file
1011rotate_log () {
8384
8485echo " Using container memory limit: ${MEM_LIMIT_MB} MB"
8586
87+ # Set GOMEMLIMIT for the Go process
88+ GOMEMLIMIT_MB=$(( MEM_LIMIT_MB * GOMEMLIMIT_PERCENT / 100 ))
89+ export GOMEMLIMIT=" ${GOMEMLIMIT_MB} MiB"
90+ echo " Setting GOMEMLIMIT to: ${GOMEMLIMIT} (${GOMEMLIMIT_PERCENT} % of ${MEM_LIMIT_MB} MB)"
91+
8692# Start memory monitoring in the background
87- while true ; do
88- check_memory_and_kill
89- sleep " $CHECK_INTERVAL_MEM "
90- done &
9193
9294while :
9395do
You can’t perform that action at this time.
0 commit comments