Example #1
0
        public void StartServer()
        {
            IgnoreCertErrorPolicy.Register();

            if (OsInfo.IsWindows)
            {
                if (_runtimeInfo.IsAdmin)
                {
                    _firewallAdapter.MakeAccessible();
                    _sslAdapter.Register();
                }

                _urlAclAdapter.ConfigureUrl();
            }

            var options = new StartOptions(_urlAclAdapter.Url)
            {
                ServerFactory = "Microsoft.Owin.Host.HttpListener"
            };

            if (_configFileProvider.EnableSsl)
            {
                _logger.Trace("SSL enabled, listening on: {0}", _urlAclAdapter.HttpsUrl);
                options.Urls.Add(_urlAclAdapter.HttpsUrl);
            }

            _logger.Info("starting server on {0}", _urlAclAdapter.Url);

            try
            {
                _host = WebApp.Start(OwinServiceProviderFactory.Create(), options, BuildApp);
            }
            catch (TargetInvocationException ex)
            {
                if (ex.InnerException == null)
                {
                    throw;
                }

                if (ex.InnerException is HttpListenerException)
                {
                    throw new PortInUseException("Port {0} is already in use, please ensure NzbDrone is not already running.",
                                                 ex,
                                                 _configFileProvider.Port);
                }

                throw ex.InnerException;
            }
        }
Example #2
0
        public void StartServer()
        {
            IgnoreCertErrorPolicy.Register();

            if (OsInfo.IsWindows)
            {
                if (_runtimeInfo.IsAdmin)
                {
                    _firewallAdapter.MakeAccessible();
                    _sslAdapter.Register();
                }
            }

            _urlAclAdapter.ConfigureUrl();

            var options = new StartOptions()
            {
                ServerFactory = "Microsoft.Owin.Host.HttpListener"
            };

            _urlAclAdapter.Urls.ForEach(options.Urls.Add);

            _logger.Info("Listening on the following URLs:");
            foreach (var url in options.Urls)
            {
                _logger.Info("  {0}", url);
            }

            try
            {
                _host = WebApp.Start(OwinServiceProviderFactory.Create(), options, BuildApp);
            }
            catch (TargetInvocationException ex)
            {
                if (ex.InnerException == null)
                {
                    throw;
                }

                if (ex.InnerException is HttpListenerException)
                {
                    throw new PortInUseException("Port {0} is already in use, please ensure NzbDrone is not already running.",
                                                 ex,
                                                 _configFileProvider.Port);
                }

                throw ex.InnerException;
            }
        }
Example #3
0
        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;
            }
        }
Example #4
0
        public static IContainer Start(StartupArguments args, IUserAlert userAlert)
        {
            var logger = NzbDroneLogger.GetLogger();

            GlobalExceptionHandlers.Register();
            IgnoreCertErrorPolicy.Register();

            logger.Info("Starting NzbDrone Console. Version {0}", Assembly.GetExecutingAssembly().GetName().Version);


            if (!PlatformValidation.IsValidate(userAlert))
            {
                throw new TerminateApplicationException();
            }

            var container = MainAppContainerBuilder.BuildContainer(args);

            DbFactory.RegisterDatabase(container);
            container.Resolve <Router>().Route();

            return(container);
        }
Example #5
0
        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);
            }
        }
Example #6
0
        public void StartServer()
        {
            IgnoreCertErrorPolicy.Register();

            if (OsInfo.IsWindows)
            {
                if (_runtimeInfo.IsAdmin)
                {
                    _firewallAdapter.MakeAccessible();
                    _sslAdapter.Register();
                }
            }

            _urlAclAdapter.ConfigureUrl();

            _logger.Info("Listening on the following URLs:");
            foreach (var url in _urlAclAdapter.Urls)
            {
                _logger.Info("  {0}", url);
            }

            _owinApp = _owinAppFactory.CreateApp(_urlAclAdapter.Urls);
        }