in Configurator/Core/Server/MySqlServerInstance.cs [1935:2068]
private ServerStartStatus StartInstanceAsServiceWithExtendedStatus(string additionalOptions = null)
{
var isSelfContainedUpgrade = !string.IsNullOrEmpty(additionalOptions)
&& additionalOptions.IndexOf("--upgrade", StringComparison.InvariantCultureIgnoreCase) >= 0;
var startStatus = new ServerStartStatus(true);
Task<ServerUpgradeStatus> parsingLogForUpgradeTask = null;
Task<bool> parsingLogTask = null;
var mySqlErrorLog = new ServerErrorLog(_controller.ErrorLogFilePath)
{
ReportStatusDelegate = ReportStatus,
ReportWaitingDelegate = _controller.ReportWaiting
};
ReportStatus(string.Format(Resources.ServerConfigEventStartServiceInfo, _controller.Settings.ServiceName));
// Initialize the async task that will parse the error log in case of a self-contained upgrade
if (isSelfContainedUpgrade)
{
parsingLogForUpgradeTask = Task.Factory.StartNew(() => mySqlErrorLog.ParseServerUpgradeMessages(_controller.ServerVersion), _controller.CancellationToken);
try
{
MySqlServiceControlManager.Start(_controller.Settings.ServiceName, _controller.CancellationToken, additionalOptions, 90);
parsingLogForUpgradeTask.Wait(_controller.CancellationToken);
if (parsingLogForUpgradeTask.IsCompleted
&& parsingLogForUpgradeTask.Result.AcceptingConnections)
{
startStatus.Started = true;
ReportStatus(string.Format(Resources.ServerConfigEventStartServiceSuccess, _controller.Settings.ServiceName));
}
}
catch (System.ServiceProcess.TimeoutException)
{
startStatus.Started = false;
ReportServerStartErrors(mySqlErrorLog.LogLines);
}
catch
{
startStatus.Started = false;
ReportStatus(string.Format(Resources.ServerConfigEventStartServiceError, _controller.Settings.ServiceName));
}
if (!startStatus.Started)
{
// One final check in case parsing log failed.
try
{
using (var ssc = new ExpandedServiceController(_controller.Settings.ServiceName))
{
if (ssc.Status == ServiceControllerStatus.Running)
{
startStatus.Started = true;
startStatus.AcceptingConnections = true;
}
}
}
catch (Exception ex)
{
Logger.LogException(ex);
throw;
}
}
// Await for the async task that parses the error log in case of a self-contained upgrade to check when the upgrade has finished
if (startStatus.Started)
{
parsingLogForUpgradeTask.Wait(_controller.CancellationToken);
startStatus.UpgradeStatus = parsingLogForUpgradeTask.IsCompleted
? parsingLogForUpgradeTask.Result
: new ServerUpgradeStatus();
startStatus.AcceptingConnections = startStatus.UpgradeStatus.AcceptingConnections;
}
parsingLogForUpgradeTask.Dispose();
}
else
{
parsingLogTask = Task.Factory.StartNew(() => mySqlErrorLog.ParseServerAcceptingConnectionMessage(_controller.ServerVersion, true, !isSelfContainedUpgrade, 90), _controller.CancellationToken);
try
{
MySqlServiceControlManager.Start(_controller.Settings.ServiceName, _controller.CancellationToken, additionalOptions, 90);
parsingLogTask.Wait(_controller.CancellationToken);
if (parsingLogTask.IsCompleted
&& parsingLogTask.Result)
{
startStatus.Started = true;
ReportStatus(string.Format(Resources.ServerConfigEventStartServiceSuccess, _controller.Settings.ServiceName));
}
}
catch (System.ServiceProcess.TimeoutException)
{
startStatus.Started = false;
ReportServerStartErrors(mySqlErrorLog.LogLines);
}
catch
{
startStatus.Started = false;
ReportStatus(string.Format(Resources.ServerConfigEventStartServiceError, _controller.Settings.ServiceName));
}
finally
{
parsingLogTask.Dispose();
}
if (!startStatus.Started)
{
// One final check in case parsing log failed.
try
{
using (var ssc = new ExpandedServiceController(_controller.Settings.ServiceName))
{
if (ssc.Status == ServiceControllerStatus.Running)
{
startStatus.Started = true;
startStatus.AcceptingConnections = true;
}
}
}
catch (Exception ex)
{
Logger.LogException(ex);
throw;
}
}
}
if (WaitUntilAcceptingConnections
&& startStatus.Started
&& (!startStatus.AcceptingConnections
|| !ParseErrorLogForAcceptingConnections))
{
startStatus.AcceptingConnections = WaitUntilConnectionSuccessful(true, MaxConnectionRetries);
}
return startStatus;
}