- you can now control the CPU limit of the running AOT process via changing the contents of /root/aot_cpu_limit (gets it's initial value from the env variable AOT_CPU_LIMIT which if set to zero imposes zero limits) - set limits on log file sizes
45 lines
1.5 KiB
Bash
45 lines
1.5 KiB
Bash
#!/bin/bash
|
|
export DISPLAY=":0.0"
|
|
CPU_LIMIT_FILE="$AOTDIR/aot_cpu_limit"
|
|
CURRENT_LIMIT=0
|
|
|
|
# Initialize the CPU limit file with AOT_CPU_LIMIT if it's set
|
|
if [ ! -z "$AOT_CPU_LIMIT" ]; then
|
|
echo "$AOT_CPU_LIMIT" > "$CPU_LIMIT_FILE"
|
|
fi
|
|
|
|
# give the x server time to start
|
|
sleep 5;
|
|
|
|
while true; do
|
|
if [ -f "$CPU_LIMIT_FILE" ]; then
|
|
NEW_LIMIT=$(cat "$CPU_LIMIT_FILE")
|
|
# Validate NEW_LIMIT is a number greater than zero
|
|
if [[ "$NEW_LIMIT" =~ ^[0-9]+$ ]]; then
|
|
# Check if the limit has changed
|
|
if [ "$NEW_LIMIT" -ne "$CURRENT_LIMIT" ]; then
|
|
# If so, update CURRENT_LIMIT
|
|
CURRENT_LIMIT="$NEW_LIMIT"
|
|
# Kill existing cpulimit process if any
|
|
AOT_PID=$(pidof AgeOfTime.exe)
|
|
CPULIMIT_PID=$(pgrep -fl "cpulimit.*\-p $(pidof AgeOfTime.exe)" | awk '{print $1}')
|
|
if [ ! -z "$CPULIMIT_PID" ]; then
|
|
echo "Killing cpulimit process $CPULIMIT_PID"
|
|
kill "$CPULIMIT_PID"
|
|
fi
|
|
# Apply new cpulimit if >= 0
|
|
if [ ! -z "$AOT_PID" ] && [ "$NEW_LIMIT" -gt 0 ]; then
|
|
echo "Creating cpulimit process (limit=$NEW_LIMIT)"
|
|
cpulimit -p "$AOT_PID" -l "$NEW_LIMIT" -b &
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if wmctrl -l | awk '{$3=""; $2=""; $1=""; print $0}' | grep '^\s*Program Error$'; then
|
|
kill $(pidof AgeOfTime.exe)
|
|
kill $(pidof winedbg)
|
|
fi
|
|
|
|
sleep 1
|
|
done |