@@ -331,8 +331,18 @@ SETUP_EXIT_CODE=255
331331PREVIOUS_LOG_TAIL=" "
332332
333333while [ $COUNTER -lt $TIMEOUT ]; do
334- # Check if setup process is still running first
335- SETUP_RUNNING=$( ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -i ~ /.ssh/id_rsa root@${VPS_IP} " pgrep -f './setup' || echo 'NOT_RUNNING'" 2> /dev/null || echo " SSH_FAILED" )
334+ # Check if setup process is still running - be more specific with process detection
335+ SETUP_RUNNING=$( ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -i ~ /.ssh/id_rsa root@${VPS_IP} " pgrep -f '^[^ ]*setup\$ ' | head -1 || echo 'NOT_RUNNING'" 2> /dev/null || echo " SSH_FAILED" )
336+
337+ # Quick check: if log shows completion indicators, exit immediately
338+ if [ $COUNTER -ge 30 ]; then # After 30 seconds, start checking for completion
339+ QUICK_SUCCESS_CHECK=$( ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -i ~ /.ssh/id_rsa root@${VPS_IP} " grep -c 'deployment_status::success\\ |🎉.*Mautic setup completed\\ |Access URL:.*login' /var/log/setup-dc.log 2>/dev/null || echo '0'" 2> /dev/null || echo " 0" )
340+ if [ " $QUICK_SUCCESS_CHECK " -gt 0 ]; then
341+ echo " ✅ Setup completed successfully (found completion indicators in log)"
342+ SETUP_EXIT_CODE=0
343+ break
344+ fi
345+ fi
336346
337347 if [ " $SETUP_RUNNING " = " NOT_RUNNING" ]; then
338348 echo " 🏁 Setup process has completed (no longer running)"
@@ -383,6 +393,14 @@ while [ $COUNTER -lt $TIMEOUT ]; do
383393 # Show memory usage to monitor for memory pressure
384394 echo " 💾 Current memory usage:"
385395 ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -i ~ /.ssh/id_rsa root@${VPS_IP} " free -h && echo 'Swap usage:' && swapon --show 2>/dev/null || echo 'No swap active'" 2> /dev/null || echo " Could not check memory"
396+
397+ # During detailed progress check, also verify if setup actually completed
398+ DETAILED_SUCCESS_CHECK=$( ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -i ~ /.ssh/id_rsa root@${VPS_IP} " grep -E 'deployment_status::success|🎉.*Mautic setup completed|Access URL:.*login' /var/log/setup-dc.log 2>/dev/null | tail -1" 2> /dev/null || echo " " )
399+ if [ -n " $DETAILED_SUCCESS_CHECK " ]; then
400+ echo " ✅ Setup actually completed successfully (found: $DETAILED_SUCCESS_CHECK )"
401+ SETUP_EXIT_CODE=0
402+ break
403+ fi
386404 else
387405 echo " ⏳ Setup running... (${COUNTER} s, PID: $SETUP_RUNNING )"
388406 fi
0 commit comments