public static void Main(string[] args) { try { var startupArgs = new StartupContext(args); NzbDroneLogger.Register(startupArgs, false, true); Bootstrap.Start(startupArgs, new ConsoleAlerts()); } catch (SocketException exception) { System.Console.WriteLine(""); System.Console.WriteLine(""); Logger.Fatal(exception.Message + ". This can happen if another instance of Sonarr is already running another application is using the same port (default: 8989) or the user has insufficient permissions"); System.Console.WriteLine("Press any key to exit..."); System.Console.ReadLine(); Environment.Exit(1); } catch (Exception e) { System.Console.WriteLine(""); System.Console.WriteLine(""); Logger.FatalException("EPIC FAIL!", e); System.Console.WriteLine("Press any key to exit..."); System.Console.ReadLine(); Environment.Exit(1); } Logger.Info("Exiting main."); //Need this to terminate on mono (thanks nlog) LogManager.Configuration = null; Environment.Exit(0); }
private MainAppContainerBuilder(StartupContext args, string[] assemblies) : base(args, assemblies) { AutoRegisterImplementations<NzbDronePersistentConnection>(); Container.Register<INancyBootstrapper, NancyBootstrapper>(); }
public void SetUp() { var args = new StartupContext("first", "second"); _container = MainAppContainerBuilder.BuildContainer(args); _container.Register<IMainDatabase>(new MainDatabase(null)); }
private MainAppContainerBuilder(StartupContext args, string[] assemblies) : base(args, assemblies) { AutoRegisterImplementations<NzbDronePersistentConnection>(); Container.Register(typeof(IBasicRepository<NamingConfig>), typeof(BasicRepository<NamingConfig>)); Container.Register<INancyBootstrapper, NancyBootstrapper>(); }
private static void Start(ApplicationModes applicationModes, StartupContext startupContext) { if (!IsInUtilityMode(applicationModes)) { EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext); } DbFactory.RegisterDatabase(_container); _container.Resolve<Router>().Route(applicationModes); }
private static void Start(ApplicationModes applicationModes, StartupContext startupContext) { if (!IsInUtilityMode(applicationModes)) { if (startupContext.Flags.Contains(StartupContext.RESTART)) { Thread.Sleep(2000); } EnsureSingleInstance(applicationModes == ApplicationModes.Service, startupContext); } DbFactory.RegisterDatabase(_container); _container.Resolve<Router>().Route(applicationModes); }
private static void EnsureSingleInstance(bool isService, StartupContext startupContext) { var instancePolicy = _container.Resolve<ISingleInstancePolicy>(); if (isService) { instancePolicy.KillAllOtherInstance(); } else if (startupContext.Flags.Contains(StartupContext.TERMINATE)) { instancePolicy.KillAllOtherInstance(); } else { instancePolicy.PreventStartIfAlreadyRunning(); } }
public static void Main(string[] args) { try { var startupArgs = new StartupContext(args); LogTargets.Register(startupArgs, false, true); Bootstrap.Start(startupArgs, new ConsoleAlerts()); } catch (Exception e) { System.Console.WriteLine(""); System.Console.WriteLine(""); Logger.FatalException("EPIC FAIL!", e); System.Console.WriteLine("Press any key to exit..."); System.Console.ReadLine(); //Need this to terminate on mono (thanks nlog) LogManager.Configuration = null; } }
public static void Start(StartupContext startupContext, IUserAlert userAlert, Action<IContainer> startCallback = null) { LogTargets.Register(startupContext, false, true); try { GlobalExceptionHandlers.Register(); IgnoreCertErrorPolicy.Register(); Logger.Info("Starting NzbDrone - {0} - Version {1}", Assembly.GetCallingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); if (!PlatformValidation.IsValidate(userAlert)) { throw new TerminateApplicationException("Missing system requirements"); } _container = MainAppContainerBuilder.BuildContainer(startupContext); _container.Resolve<IAppFolderFactory>().Register(); _container.Resolve<IProvidePidFile>().Write(); var appMode = GetApplicationMode(startupContext); Start(appMode, startupContext); if (startCallback != null) { startCallback(_container); } else { SpinToExit(appMode); } } catch (TerminateApplicationException e) { Logger.Info(e.Message); LogManager.Configuration = null; } }
public static void Main(string[] args) { try { var startupArgs = new StartupContext(args); LogTargets.Register(startupArgs, false, true); Bootstrap.Start(startupArgs, new MessageBoxUserAlert(), container => { container.Register<ISystemTrayApp, SystemTrayApp>(); var trayApp = container.Resolve<ISystemTrayApp>(); trayApp.Start(); }); } catch (Exception e) { Logger.FatalException("EPIC FAIL: " + e.Message, e); var message = string.Format("{0}: {1}", e.GetType().Name, e.Message); MessageBox.Show(text: message, buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error, caption: "Epic Fail!"); } }
public static IContainer BuildContainer(StartupContext args) { var assemblies = new List<string> { "NzbDrone.Host", "NzbDrone.Common", "NzbDrone.Core", "NzbDrone.Api", "NzbDrone.SignalR" }; if (OsInfo.IsWindows) { assemblies.Add("NzbDrone.Windows"); } else { assemblies.Add("NzbDrone.Mono"); } return new MainAppContainerBuilder(args, assemblies.ToArray()).Container; }
public static void Main(string[] args) { try { var startupArgument = new StartupContext(args); LogTargets.Register(startupArgument, true, true); Console.WriteLine("Starting NzbDrone Update Client"); IgnoreCertErrorPolicy.Register(); GlobalExceptionHandlers.Register(); _container = UpdateContainerBuilder.Build(startupArgument); logger.Info("Updating NzbDrone to version {0}", BuildInfo.Version); _container.Resolve<UpdateApp>().Start(args); } catch (Exception e) { logger.FatalException("An error has occurred while applying update package.", e); } }
public static void Main(string[] args) { try { var startupArgument = new StartupContext(args); NzbDroneLogger.Register(startupArgument, true, true); Logger.Info("Starting Sonarr Update Client"); X509CertificateValidationPolicy.Register(); _container = UpdateContainerBuilder.Build(startupArgument); Logger.Info("Updating Sonarr to version {0}", BuildInfo.Version); _container.Resolve<UpdateApp>().Start(args); Logger.Info("Update compleded successfully"); } catch (Exception e) { Logger.FatalException("An error has occurred while applying update package.", e); } }
public void should_parse_single_flag(string arg) { var args = new StartupContext(new[] { arg }); args.Flags.Should().HaveCount(1); args.Flags.Contains("t").Should().BeTrue(); }
public void should_preserver_no_browser(string arg, string preserved) { var args = new StartupContext(new[] { arg }); args.PreservedArguments.Should().Be(preserved); }
public void should_preserver_both() { var args = new StartupContext(new[] { "/data=test", "/Nobrowser" }); args.PreservedArguments.Should().Be("/data=test /nobrowser"); }
private static ApplicationModes GetApplicationMode(StartupContext startupContext) { if (startupContext.Flags.Contains(StartupContext.HELP)) { return ApplicationModes.Help; } if (!OsInfo.IsMono && startupContext.InstallService) { return ApplicationModes.InstallService; } if (!OsInfo.IsMono && startupContext.UninstallService) { return ApplicationModes.UninstallService; } if (_container.Resolve<IRuntimeInfo>().IsWindowsService) { return ApplicationModes.Service; } return ApplicationModes.Interactive; }
public void should_parse_args_with_alues(string arg) { var args = new StartupContext(new[] { arg }); args.Args.Should().HaveCount(1); args.Args["key"].Should().Be("value"); }
public void empty_array_should_return_empty_flags() { var args = new StartupContext(new string[0]); args.Flags.Should().BeEmpty(); }