in Configurator/Program.cs [108:222]
static int Main()
{
_assemblyLoaded = false;
try
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
#if DEBUG
/* Before debugging, update the path to the server installation directory in the "installationDirectory" key of the app.config file.
The path set as the installation directory must be the root directory of the server installation.
This directory is expected to contain the bin, share, etc and other server directories.
For MSI installations this path is usually "C:\Program Files\MySQL\MySQL Server 8.1" or the custom path set during installation.
For ZIP installations this path is whichever location where the server files were extracted to.
*/
_installDirPath = ConfigurationManager.AppSettings["installationDirectory"];
#endif
#if COMMERCIAL
AppConfiguration.License = LicenseType.Commercial;
#else
AppConfiguration.License = LicenseType.Community;
#endif
// Parse command line options.
var processingResult = ParseCommandLineArguments();
Utilities.InitializeLogger(AppConfiguration.ConsoleMode);
if (processingResult.ExitCode != ExitCode.Success)
{
return PrintAndReturnExitCode(processingResult);
}
// Set configuration type and execution mode.
ServerInstallation serverInstallation = ServerInstallationManager.LoadServerInstallation(_version, _installDirPath);
processingResult = SetConfigurationTypeAndExecutionMode(serverInstallation);
if (processingResult.ExitCode != ExitCode.Success)
{
return PrintAndReturnExitCode(processingResult);
}
Application.ApplicationExit += ApplicationExit;
if (AppConfiguration.ConsoleMode)
{
Console.WriteLine(Resources.CLIRunningInConsoleMode);
var exitCode = CommandLine.ProcessCommandLineOptions(serverInstallation);
return PrintAndReturnExitCode(exitCode);
}
CustomizeUtilityDialogs();
// Make sure our app cannot run twice.
var exists = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Count() > 1;
if (exists)
{
InfoDialog.ShowDialog(InfoDialogProperties.GetErrorDialogProperties(Resources.AppName, Resources.AppAlreadyRunning));
return PrintAndReturnExitCode(new CLIExitCode(ExitCode.MultipleInstances));
}
// Do not show form if running in removal mode and option --show-removal-warning was not provided.
if (AppConfiguration.ExecutionMode == ExecutionMode.RemoveNoShow)
{
var controller = serverInstallation.Controller;
if (controller == null)
{
throw new ArgumentNullException(nameof(controller));
}
if (!controller.IsRemovalExecutionNeeded)
{
Logger.LogWarning(string.Format(Resources.RemoveWithNoUIWarningMessage));
return PrintAndReturnExitCode(new CLIExitCode(ExitCode.Success));
}
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm(serverInstallation));
return PrintAndReturnExitCode(new CLIExitCode(ExitCode.Success));
}
catch (ConfiguratorException ex)
{
if (!AppConfiguration.ConsoleMode)
{
InfoDialog.ShowDialog(InfoDialogProperties.GetErrorDialogProperties("Error loading the specified MySQL Server product", ex.Message));
}
else
{
Console.WriteLine(ex.Message);
}
Logger.LogError(ex.Message);
return PrintAndReturnExitCode(new CLIExitCode(ExitCode.GeneralError));
}
catch (Exception ex)
{
ReportUnhandledException(ex);
#if (DEBUG)
// For internal debug only.
throw;
#endif
}
finally
{
if (AppConfiguration.ConsoleMode)
{
FreeConsole();
}
Logger.LogInformation("Configurator exit");
}
#if (!DEBUG)
// For internal debug only.
return PrintAndReturnExitCode(new CLIExitCode(ExitCode.Success));
#endif
}