- check-syntax.sh: Pre-compilation syntax checker for MT4→MT5 issues - metaeditor-watchdog.sh: Auto-kills stuck MetaEditor processes - safe-compile.sh: Wrapper with 2-minute timeout for compilations These tools help prevent the container freeze that occurred when trying to compile OrdersEA with 100 MT4 syntax errors.
24 lines
908 B
Bash
Executable File
24 lines
908 B
Bash
Executable File
#!/bin/bash
|
|
# Watchdog to kill stuck MetaEditor processes
|
|
|
|
while true; do
|
|
# Find MetaEditor processes running for more than 5 minutes with high CPU
|
|
docker exec mt5 sh -c '
|
|
ps aux | grep metaeditor64 | grep -v grep | while read line; do
|
|
pid=$(echo $line | awk "{print \$2}")
|
|
cpu=$(echo $line | awk "{print \$3}")
|
|
time=$(echo $line | awk "{print \$10}")
|
|
# Kill if running more than 5 mins or using >50% CPU for >2 mins
|
|
if echo "$time" | grep -qE "[5-9]:[0-9]{2}|[0-9]{2,}:"; then
|
|
echo "Killing long-running MetaEditor: $pid (time: $time)"
|
|
kill -9 $pid 2>/dev/null
|
|
elif [ "${cpu%.*}" -gt 50 ] 2>/dev/null; then
|
|
echo "Killing high-CPU MetaEditor: $pid (CPU: $cpu%)"
|
|
kill -9 $pid 2>/dev/null
|
|
fi
|
|
done
|
|
' 2>/dev/null
|
|
|
|
sleep 60
|
|
done
|