#!/bin/bash # Safe compilation wrapper echo "=== Safe Compile Mode ===" echo "" echo "1. Checking file syntax first..." echo "" echo "2. Killing any existing MetaEditor processes..." docker exec mt5 pkill -9 metaeditor64 2>/dev/null sleep 2 echo "" echo "3. Starting MetaEditor in background with timeout..." # MetaEditor has 2 minute timeout timeout 120 docker exec mt5 wine "/config/.wine/drive_c/Program Files/MetaTrader 5/metaeditor64.exe" "$@" 2>&1 & PID=$! echo "" echo "4. Monitoring for 2 minutes max..." wait $PID EXITCODE=$? if [ $EXITCODE -eq 124 ]; then echo "⚠️ Compilation timed out - MetaEditor was killed" docker exec mt5 pkill -9 metaeditor64 2>/dev/null elif [ $EXITCODE -eq 0 ]; then echo "✅ Compilation completed" else echo "⚠️ Compilation exited with code $EXITCODE" fi