예제 #1
0
        private WaitHandle StartHost(IHostController host, IStartupArguments args)
        {
            var handle = new ManualResetEvent(false);
            new Thread(() =>
            {
                try
                {
                    host.Initialize();
                    host.Start(args);
                }
                catch (Exception ex)
                {
                    log.Error(string.Format("Failed to start '{0}'", host.Name), ex);
                }
                finally
                {
                    try
                    {
                        handle.Set();
                    }
                    catch (Exception ex)
                    {
                        log.Error("Failed to set handle signalling host started.", ex);
                    }
                }
            })
            {
                IsBackground = true
            }.Start();

            return handle;
        }
예제 #2
0
        public AppFolderInfo(IDiskProvider diskProvider, IStartupArguments startupArguments)
        {
            _diskProvider = diskProvider;

            if (OsInfo.IsLinux)
            {
                DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData;
            }

            _logger = NzbDroneLogger.GetLogger(this);

            if (startupArguments.Args.ContainsKey(StartupArguments.APPDATA))
            {
                AppDataFolder = startupArguments.Args[StartupArguments.APPDATA];
            }
            else
            {
                AppDataFolder = Path.Combine(Environment.GetFolderPath(DATA_SPECIAL_FOLDER, Environment.SpecialFolderOption.None), "NzbDrone");
            }

            _diskProvider.EnsureFolder(AppDataFolder);

            StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            TempFolder    = Path.GetTempPath();

            diskProvider.EnsureFolder(AppDataFolder);

            if (!OsInfo.IsLinux)
            {
                SetPermissions();
            }
        }
예제 #3
0
        public static void Register(IStartupArguments startupArguments, bool updateApp, bool inConsole)
        {
            var appFolderInfo = new AppFolderInfo(new DiskProvider(), startupArguments);

            LogManager.Configuration = new LoggingConfiguration();

            RegisterExceptron();

            if (updateApp)
            {
                RegisterLoggly();
                RegisterUpdateFile(appFolderInfo);
            }
            else
            {
                if (inConsole && (OsInfo.IsLinux || new RuntimeInfo(null).IsUserInteractive))
                {
                    RegisterConsole();
                }

                RegisterAppFile(appFolderInfo);
            }

            LogManager.ReconfigExistingLoggers();
        }
예제 #4
0
        public AppFolderInfo(IDiskProvider diskProvider, IStartupArguments startupArguments)
        {
            _diskProvider = diskProvider;

            if (OsInfo.IsLinux)
            {
                DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData;
            }

            _logger =  NzbDroneLogger.GetLogger(this);

            if (startupArguments.Args.ContainsKey(StartupArguments.APPDATA))
            {
                AppDataFolder = startupArguments.Args[StartupArguments.APPDATA];
            }
            else
            {
                AppDataFolder = Path.Combine(Environment.GetFolderPath(DATA_SPECIAL_FOLDER, Environment.SpecialFolderOption.None), "NzbDrone");
            }

            _diskProvider.EnsureFolder(AppDataFolder);

            StartUpFolder = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName;
            TempFolder = Path.GetTempPath();

            diskProvider.EnsureFolder(AppDataFolder);

            if (!OsInfo.IsLinux)
            {
                SetPermissions();
            }
        }
예제 #5
0
 public Router(INzbDroneServiceFactory nzbDroneServiceFactory, IServiceProvider serviceProvider, IStartupArguments startupArguments,
                 IConsoleService consoleService, IRuntimeInfo runtimeInfo, Logger logger)
 {
     _nzbDroneServiceFactory = nzbDroneServiceFactory;
     _serviceProvider = serviceProvider;
     _startupArguments = startupArguments;
     _consoleService = consoleService;
     _runtimeInfo = runtimeInfo;
     _logger = logger;
 }
예제 #6
0
 public Router(INzbDroneServiceFactory nzbDroneServiceFactory, IServiceProvider serviceProvider, IStartupArguments startupArguments,
               IConsoleService consoleService, IRuntimeInfo runtimeInfo, Logger logger)
 {
     _nzbDroneServiceFactory = nzbDroneServiceFactory;
     _serviceProvider        = serviceProvider;
     _startupArguments       = startupArguments;
     _consoleService         = consoleService;
     _runtimeInfo            = runtimeInfo;
     _logger = logger;
 }
예제 #7
0
 public NzbDroneServiceFactory(IConfigFileProvider configFileProvider, IHostController hostController, IRuntimeInfo runtimeInfo,
                               IProcessProvider processProvider, PriorityMonitor priorityMonitor, IStartupArguments startupArguments, Logger logger)
 {
     _configFileProvider = configFileProvider;
     _hostController     = hostController;
     _runtimeInfo        = runtimeInfo;
     _processProvider    = processProvider;
     _priorityMonitor    = priorityMonitor;
     _startupArguments   = startupArguments;
     _logger             = logger;
 }
예제 #8
0
 public NzbDroneServiceFactory(IConfigFileProvider configFileProvider, IHostController hostController, IRuntimeInfo runtimeInfo,
                    IProcessProvider processProvider, PriorityMonitor priorityMonitor, IStartupArguments startupArguments, Logger logger)
 {
     _configFileProvider = configFileProvider;
     _hostController = hostController;
     _runtimeInfo = runtimeInfo;
     _processProvider = processProvider;
     _priorityMonitor = priorityMonitor;
     _startupArguments = startupArguments;
     _logger = logger;
 }
예제 #9
0
        protected ContainerBuilderBase(IStartupArguments args, params string[] assemblies)
        {
            _loadedTypes = new List <Type>();

            foreach (var assembly in assemblies)
            {
                _loadedTypes.AddRange(Assembly.Load(assembly).GetTypes());
            }

            Container = new Container(new TinyIoCContainer(), _loadedTypes);
            AutoRegisterInterfaces();
            Container.Register(args);
        }
예제 #10
0
        public void Start(IStartupArguments arguments)
        {
            lock (locker)
            {
                if (Status == HostStatus.Initialized || Status == HostStatus.Stopped)
                {
                    WriteLog("Starting service.");
                    Status = HostStatus.Starting;
                    Bootstrapper.Start();

                    Status = HostStatus.Running;
                    WriteLog("Service running.");
                }
            }
        }
예제 #11
0
        public void Run(IStartupArguments args)
        {
            // create hosts for directories found by scanner
            foreach (var host in DirectoryScanner.Scan().Select(directory => HostFactory.CreateController(this, directory)))
                Hosts.Add(host);

            // start and wait for hosts
            var handles = Hosts.Select(host => StartHost(host, args)).ToArray();
            if (handles.Length != 0)
            {
                if (!WaitHandle.WaitAll(handles, TimeSpan.FromSeconds(120)))
                {
                    log.Warn("Services have taken longer than 2 minutes to start.");
                }
            }

            handles.DisposeAll();

            log.Info("Services running.");
            foreach (var host in Hosts)
                log.Info(string.Format("{0}: {1}", host.Name, host.Status));
        }
예제 #12
0
 private UpdateContainerBuilder(IStartupArguments startupArguments)
     : base(startupArguments, "NzbDrone.Update", "NzbDrone.Common")
 {
 }
예제 #13
0
 public static IContainer Build(IStartupArguments startupArguments)
 {
     return(new UpdateContainerBuilder(startupArguments).Container);
 }
예제 #14
0
        public void Start(IStartupArguments arguments)
        {
            StartArguments = arguments;
            MonitoringTask.Start();

            Initialize();
            Start();
        }
예제 #15
0
        private UpdateContainerBuilder(IStartupArguments startupArguments)
            : base(startupArguments, "NzbDrone.Update", "NzbDrone.Common")
        {

        }
예제 #16
0
 public static IContainer Build(IStartupArguments startupArguments)
 {
     return new UpdateContainerBuilder(startupArguments).Container;
 }