/// <summary> /// task that initializes application and starts the application monitoring and runtime tasks /// </summary> /// <returns></returns> private static async Task LaunchAsync(string[] args) { restart: ITranslationLookup translationLookup = null; var logger = BuildDefaultLogger <Program>(new ApplicationConfiguration()); Utilities.DefaultLogger = logger; IServiceCollection services = null; logger.LogInformation("Begin IW4MAdmin startup. Version is {version} {@args}", Version, args); try { // do any needed housekeeping file/folder migrations ConfigurationMigration.MoveConfigFolder10518(null); ConfigurationMigration.CheckDirectories(); ConfigurationMigration.RemoveObsoletePlugins20210322(); logger.LogDebug("Configuring services..."); services = ConfigureServices(args); serviceProvider = services.BuildServiceProvider(); var versionChecker = serviceProvider.GetRequiredService <IMasterCommunication>(); ServerManager = (ApplicationManager)serviceProvider.GetRequiredService <IManager>(); translationLookup = serviceProvider.GetRequiredService <ITranslationLookup>(); await versionChecker.CheckVersion(); await ServerManager.Init(); } catch (Exception e) { string failMessage = translationLookup == null ? "Failed to initialize IW4MAdmin" : translationLookup["MANAGER_INIT_FAIL"]; string exitMessage = translationLookup == null ? "Press enter to exit..." : translationLookup["MANAGER_EXIT"]; logger.LogCritical(e, "Failed to initialize IW4MAdmin"); Console.WriteLine(failMessage); while (e.InnerException != null) { e = e.InnerException; } if (e is ConfigurationException configException) { if (translationLookup != null) { Console.WriteLine(translationLookup[configException.Message] .FormatExt(configException.ConfigurationFileName)); } foreach (string error in configException.Errors) { Console.WriteLine(error); } } else { Console.WriteLine(e.Message); } Console.WriteLine(exitMessage); await Console.In.ReadAsync(new char[1], 0, 1); return; } try { ApplicationTask = RunApplicationTasksAsync(logger, services); await ApplicationTask; } catch (Exception e) { logger.LogCritical(e, "Failed to launch IW4MAdmin"); string failMessage = translationLookup == null ? "Failed to launch IW4MAdmin" : translationLookup["MANAGER_INIT_FAIL"]; Console.WriteLine($"{failMessage}: {e.GetExceptionInfo()}"); } if (ServerManager.IsRestartRequested) { goto restart; } serviceProvider.Dispose(); }