From 7fcd674b7fdb99d6d565f1da0961bccf15a273d2 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Mon, 24 Jun 2024 19:30:20 +0200 Subject: [PATCH] Improved mysql container boot state error handling --- Moonlight/Program.cs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Moonlight/Program.cs b/Moonlight/Program.cs index ce531bc7..44fea258 100644 --- a/Moonlight/Program.cs +++ b/Moonlight/Program.cs @@ -108,18 +108,31 @@ try } catch (MySqlException e) { - if (e.InnerException is EndOfStreamException eosException) + bool IsBootException(MySqlException e) { - if (eosException.Message.Contains("read 4 header bytes")) + if (e.InnerException is EndOfStreamException eosException) { - preRunLogger.LogWarning("The mysql server appears to be still booting up. Exiting..."); - - Environment.Exit(1); - return; + if (!eosException.Message.Contains("read 4 header bytes")) + return false; } + else if (e.InnerException is MySqlEndOfStreamException endOfStreamException) + { + if (!endOfStreamException.Message.Contains("An incomplete response was received from the server")) + return false; + } + else + return false; + + return true; } - throw; + if (IsBootException(e)) + { + preRunLogger.LogWarning("The mysql server appears to be still booting up. Exiting..."); + + Environment.Exit(1); + return; + } } // Add pre constructed services