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; }
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(); } }
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(); }
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; }
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; }
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); }
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."); } } }
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)); }
private UpdateContainerBuilder(IStartupArguments startupArguments) : base(startupArguments, "NzbDrone.Update", "NzbDrone.Common") { }
public static IContainer Build(IStartupArguments startupArguments) { return(new UpdateContainerBuilder(startupArguments).Container); }
public void Start(IStartupArguments arguments) { StartArguments = arguments; MonitoringTask.Start(); Initialize(); Start(); }
public static IContainer Build(IStartupArguments startupArguments) { return new UpdateContainerBuilder(startupArguments).Container; }