Improved mysql container boot state error handling

This commit is contained in:
Marcel Baumgartner
2024-06-24 19:30:20 +02:00
parent 42e9f18fb6
commit 7fcd674b7f

View File

@@ -107,10 +107,26 @@ try
);
}
catch (MySqlException e)
{
bool IsBootException(MySqlException e)
{
if (e.InnerException is EndOfStreamException eosException)
{
if (eosException.Message.Contains("read 4 header bytes"))
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;
}
if (IsBootException(e))
{
preRunLogger.LogWarning("The mysql server appears to be still booting up. Exiting...");
@@ -119,9 +135,6 @@ catch (MySqlException e)
}
}
throw;
}
// Add pre constructed services
builder.Services.AddSingleton(featureService);
builder.Services.AddSingleton(configService);