public static void Start(StartupContext startupContext, IUserAlert userAlert, Action <IContainer> startCallback = null) { try { SecurityProtocolPolicy.Register(); X509CertificateValidationPolicy.Register(); Logger.Info("Starting Gamearr - {0} - Version {1}", Assembly.GetCallingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); if (!PlatformValidation.IsValidate(userAlert)) { throw new TerminateApplicationException("Missing system requirements"); } LongPathSupport.Enable(); _container = MainAppContainerBuilder.BuildContainer(startupContext); _container.Resolve <InitializeLogger>().Initialize(); _container.Resolve <IAppFolderFactory>().Register(); _container.Resolve <IProvidePidFile>().Write(); var appMode = GetApplicationMode(startupContext); Start(appMode, startupContext); if (startCallback != null) { startCallback(_container); } else { SpinToExit(appMode); } } catch (InvalidConfigFileException ex) { throw new GamearrStartupException(ex); } catch (AccessDeniedConfigFileException ex) { throw new GamearrStartupException(ex); } catch (TerminateApplicationException ex) { Logger.Info(ex.Message); LogManager.Configuration = null; } }
public static void Start(string[] args, Action <IHostBuilder> trayCallback = null) { try { Logger.Info("Starting Readarr - {0} - Version {1}", Assembly.GetCallingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); var startupContext = new StartupContext(args); LongPathSupport.Enable(); var appMode = GetApplicationMode(startupContext); switch (appMode) { case ApplicationModes.Service: { Logger.Debug("Service selected"); CreateConsoleHostBuilder(args, startupContext).UseWindowsService().Build().Run(); break; } case ApplicationModes.Interactive: { Logger.Debug(trayCallback != null ? "Tray selected" : "Console selected"); var builder = CreateConsoleHostBuilder(args, startupContext); if (trayCallback != null) { trayCallback(builder); } builder.Build().Run(); break; } // Utility mode default: { new Container(rules => rules.WithNzbDroneRules()) .AutoAddServices(ASSEMBLIES) .AddNzbDroneLogger() .AddStartupContext(startupContext) .Resolve <UtilityModeRouter>() .Route(appMode); break; } } } catch (InvalidConfigFileException ex) { throw new ReadarrStartupException(ex); } catch (AccessDeniedConfigFileException ex) { throw new ReadarrStartupException(ex); } catch (TerminateApplicationException ex) { Logger.Info(ex.Message); LogManager.Configuration = null; } }