mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
main app cleanup.
This commit is contained in:
parent
da2c0d1d65
commit
8900bbb3a1
@ -11,14 +11,14 @@ public class CentralDispatchTests : TestBase
|
||||
[Test]
|
||||
public void Kernel_can_get_kernel()
|
||||
{
|
||||
CentralDispatch.Container.Should().NotBeNull();
|
||||
NzbDroneBootstrapper.Container.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Kernel_should_return_same_kernel()
|
||||
{
|
||||
var firstKernel = CentralDispatch.Container;
|
||||
var secondKernel = CentralDispatch.Container;
|
||||
var firstKernel = NzbDroneBootstrapper.Container;
|
||||
var secondKernel = NzbDroneBootstrapper.Container;
|
||||
|
||||
firstKernel.Should().BeSameAs(secondKernel);
|
||||
}
|
||||
@ -26,7 +26,7 @@ public void Kernel_should_return_same_kernel()
|
||||
[Test]
|
||||
public void Kernel_should_be_able_to_resolve_ApplicationServer()
|
||||
{
|
||||
var appServer = CentralDispatch.Container.Resolve<ApplicationServer>();
|
||||
var appServer = NzbDroneBootstrapper.Container.Resolve<ApplicationServer>();
|
||||
|
||||
appServer.Should().NotBeNull();
|
||||
}
|
||||
@ -34,8 +34,8 @@ public void Kernel_should_be_able_to_resolve_ApplicationServer()
|
||||
[Test]
|
||||
public void Kernel_should_resolve_same_ApplicationServer_instance()
|
||||
{
|
||||
var appServer1 = CentralDispatch.Container.Resolve<ApplicationServer>();
|
||||
var appServer2 = CentralDispatch.Container.Resolve<ApplicationServer>();
|
||||
var appServer1 = NzbDroneBootstrapper.Container.Resolve<ApplicationServer>();
|
||||
var appServer2 = NzbDroneBootstrapper.Container.Resolve<ApplicationServer>();
|
||||
|
||||
appServer1.Should().BeSameAs(appServer2);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Model;
|
||||
using NzbDrone.Providers;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
@ -24,14 +23,14 @@ public void Ensure_priority_doesnt_fail_on_invalid_iis_proccess_id()
|
||||
|
||||
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetProcessById(It.IsAny<int>())).Returns((ProcessInfo)null);
|
||||
|
||||
Mocker.Resolve<MonitoringProvider>().EnsurePriority(null);
|
||||
Mocker.Resolve<PriorityMonitor>().EnsurePriority(null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Ensure_should_log_warn_exception_rather_than_throw()
|
||||
{
|
||||
Mocker.GetMock<ProcessProvider>().Setup(c => c.GetCurrentProcess()).Throws<InvalidOperationException>();
|
||||
Mocker.Resolve<MonitoringProvider>().EnsurePriority(null);
|
||||
Mocker.Resolve<PriorityMonitor>().EnsurePriority(null);
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
using System.IO;
|
||||
using System.ServiceProcess;
|
||||
using System.ServiceProcess;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Model;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.App.Test
|
||||
{
|
||||
@ -14,34 +11,34 @@ namespace NzbDrone.App.Test
|
||||
public class RouterTest : TestBase
|
||||
{
|
||||
|
||||
[TestCase(null, ApplicationMode.Console)]
|
||||
[TestCase("", ApplicationMode.Console)]
|
||||
[TestCase("1", ApplicationMode.Help)]
|
||||
[TestCase("ii", ApplicationMode.Help)]
|
||||
[TestCase("uu", ApplicationMode.Help)]
|
||||
[TestCase("i", ApplicationMode.InstallService)]
|
||||
[TestCase("I", ApplicationMode.InstallService)]
|
||||
[TestCase("/I", ApplicationMode.InstallService)]
|
||||
[TestCase("/i", ApplicationMode.InstallService)]
|
||||
[TestCase("-I", ApplicationMode.InstallService)]
|
||||
[TestCase("-i", ApplicationMode.InstallService)]
|
||||
[TestCase("u", ApplicationMode.UninstallService)]
|
||||
[TestCase("U", ApplicationMode.UninstallService)]
|
||||
[TestCase("/U", ApplicationMode.UninstallService)]
|
||||
[TestCase("/u", ApplicationMode.UninstallService)]
|
||||
[TestCase("-U", ApplicationMode.UninstallService)]
|
||||
[TestCase("-u", ApplicationMode.UninstallService)]
|
||||
public void GetApplicationMode_single_arg(string arg, ApplicationMode mode)
|
||||
[TestCase(null, ApplicationModes.Console)]
|
||||
[TestCase("", ApplicationModes.Console)]
|
||||
[TestCase("1", ApplicationModes.Help)]
|
||||
[TestCase("ii", ApplicationModes.Help)]
|
||||
[TestCase("uu", ApplicationModes.Help)]
|
||||
[TestCase("i", ApplicationModes.InstallService)]
|
||||
[TestCase("I", ApplicationModes.InstallService)]
|
||||
[TestCase("/I", ApplicationModes.InstallService)]
|
||||
[TestCase("/i", ApplicationModes.InstallService)]
|
||||
[TestCase("-I", ApplicationModes.InstallService)]
|
||||
[TestCase("-i", ApplicationModes.InstallService)]
|
||||
[TestCase("u", ApplicationModes.UninstallService)]
|
||||
[TestCase("U", ApplicationModes.UninstallService)]
|
||||
[TestCase("/U", ApplicationModes.UninstallService)]
|
||||
[TestCase("/u", ApplicationModes.UninstallService)]
|
||||
[TestCase("-U", ApplicationModes.UninstallService)]
|
||||
[TestCase("-u", ApplicationModes.UninstallService)]
|
||||
public void GetApplicationMode_single_arg(string arg, ApplicationModes modes)
|
||||
{
|
||||
Router.GetApplicationMode(new[] { arg }).Should().Be(mode);
|
||||
Router.GetApplicationMode(new[] { arg }).Should().Be(modes);
|
||||
}
|
||||
|
||||
[TestCase("", "", ApplicationMode.Console)]
|
||||
[TestCase("", null, ApplicationMode.Console)]
|
||||
[TestCase("i", "n", ApplicationMode.Help)]
|
||||
public void GetApplicationMode_two_args(string a, string b, ApplicationMode mode)
|
||||
[TestCase("", "", ApplicationModes.Console)]
|
||||
[TestCase("", null, ApplicationModes.Console)]
|
||||
[TestCase("i", "n", ApplicationModes.Help)]
|
||||
public void GetApplicationMode_two_args(string a, string b, ApplicationModes modes)
|
||||
{
|
||||
Router.GetApplicationMode(new[] { a, b }).Should().Be(mode);
|
||||
Router.GetApplicationMode(new[] { a, b }).Should().Be(modes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -53,7 +50,7 @@ public void Route_should_call_install_service_when_application_mode_is_install()
|
||||
serviceProviderMock.Setup(c => c.Start(ServiceProvider.NZBDRONE_SERVICE_NAME));
|
||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||
|
||||
Mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
|
||||
Mocker.Resolve<Router>().Route(ApplicationModes.InstallService);
|
||||
|
||||
serviceProviderMock.Verify(c => c.Install(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
|
||||
}
|
||||
@ -67,7 +64,7 @@ public void Route_should_call_uninstall_service_when_application_mode_is_uninsta
|
||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||
serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
||||
|
||||
Mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
|
||||
Mocker.Resolve<Router>().Route(ApplicationModes.UninstallService);
|
||||
|
||||
serviceProviderMock.Verify(c => c.UnInstall(ServiceProvider.NZBDRONE_SERVICE_NAME), Times.Once());
|
||||
}
|
||||
@ -81,17 +78,17 @@ public void Route_should_call_console_service_when_application_mode_is_console()
|
||||
appServerProvider.Setup(c => c.Start());
|
||||
Mocker.GetMock<EnvironmentProvider>().SetupGet(c => c.IsUserInteractive).Returns(true);
|
||||
|
||||
Mocker.Resolve<Router>().Route(ApplicationMode.Console);
|
||||
Mocker.Resolve<Router>().Route(ApplicationModes.Console);
|
||||
|
||||
consoleProvider.Verify(c => c.WaitForClose(), Times.Once());
|
||||
appServerProvider.Verify(c => c.Start(), Times.Once());
|
||||
}
|
||||
|
||||
[TestCase(ApplicationMode.Console)]
|
||||
[TestCase(ApplicationMode.InstallService)]
|
||||
[TestCase(ApplicationMode.UninstallService)]
|
||||
[TestCase(ApplicationMode.Help)]
|
||||
public void Route_should_call_service_start_when_run_in_service_more(ApplicationMode applicationMode)
|
||||
[TestCase(ApplicationModes.Console)]
|
||||
[TestCase(ApplicationModes.InstallService)]
|
||||
[TestCase(ApplicationModes.UninstallService)]
|
||||
[TestCase(ApplicationModes.Help)]
|
||||
public void Route_should_call_service_start_when_run_in_service_more(ApplicationModes applicationModes)
|
||||
{
|
||||
var envMock = Mocker.GetMock<EnvironmentProvider>();
|
||||
var serviceProvider = Mocker.GetMock<ServiceProvider>();
|
||||
@ -100,7 +97,7 @@ public void Route_should_call_service_start_when_run_in_service_more(Application
|
||||
|
||||
serviceProvider.Setup(c => c.Run(It.IsAny<ServiceBase>()));
|
||||
|
||||
Mocker.Resolve<Router>().Route(applicationMode);
|
||||
Mocker.Resolve<Router>().Route(applicationModes);
|
||||
|
||||
serviceProvider.Verify(c => c.Run(It.IsAny<ServiceBase>()), Times.Once());
|
||||
}
|
||||
@ -116,7 +113,7 @@ public void show_error_on_install_if_service_already_exist()
|
||||
consoleMock.Setup(c => c.PrintServiceAlreadyExist());
|
||||
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(true);
|
||||
|
||||
Mocker.Resolve<Router>().Route(ApplicationMode.InstallService);
|
||||
Mocker.Resolve<Router>().Route(ApplicationModes.InstallService);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
@ -131,7 +128,7 @@ public void show_error_on_uninstall_if_service_doesnt_exist()
|
||||
consoleMock.Setup(c => c.PrintServiceDoestExist());
|
||||
serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)).Returns(false);
|
||||
|
||||
Mocker.Resolve<Router>().Route(ApplicationMode.UninstallService);
|
||||
Mocker.Resolve<Router>().Route(ApplicationModes.UninstallService);
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
|
@ -35,11 +35,12 @@ public HostController(ConfigFileProvider configFileProvider, INancyBootstrapper
|
||||
public void StartServer()
|
||||
{
|
||||
_host = new NancyHost(new Uri(AppUrl), _bootstrapper);
|
||||
_host.Start();
|
||||
}
|
||||
|
||||
public string AppUrl
|
||||
{
|
||||
get { return string.Format("http://localhost:{0}/", _configFileProvider.Port); }
|
||||
get { return string.Format("http://localhost:{0}", _configFileProvider.Port); }
|
||||
}
|
||||
|
||||
|
||||
|
24
NzbDrone.Console/AppMain.cs
Normal file
24
NzbDrone.Console/AppMain.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Console
|
||||
{
|
||||
public static class AppMain
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
NzbDrone.AppMain.Main(args);
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
System.Console.WriteLine("Press enter to exit...");
|
||||
System.Console.ReadLine();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
<ProjectGuid>{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NzbDrone</RootNamespace>
|
||||
<RootNamespace>NzbDrone.Console</RootNamespace>
|
||||
<AssemblyName>NzbDrone.Console</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
@ -36,7 +36,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<OutputPath>..\NzbDrone\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@ -55,75 +55,35 @@
|
||||
<IntermediateOutputPath>C:\Users\Mark\AppData\Local\Temp\vs1A55.tmp\x86\Release\</IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>NzbDrone.ico</ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject>NzbDrone.AppMain</StartupObject>
|
||||
<StartupObject>NzbDrone.Console.AppMain</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Autofac.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Exceptron.Client, Version=1.0.20.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Exceptron.Client.1.0.20\lib\net20\Exceptron.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Exceptron.NLog">
|
||||
<HintPath>..\packages\Exceptron.Nlog.1.0.11\lib\net20\Exceptron.NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Bootstrappers.Autofac, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Bootstrappers.Autofac.0.16.1\lib\net40\Nancy.Bootstrappers.Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Hosting.Self, Version=0.16.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Nancy.Hosting.Self.0.16.1\lib\net40\Nancy.Hosting.Self.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NzbDrone.Common\Properties\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ApplicationServer.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CentralDispatch.cs" />
|
||||
<Compile Include="Model\ApplicationMode.cs" />
|
||||
<Compile Include="AppMain.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\MonitoringProvider.cs" />
|
||||
<Compile Include="Router.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="NLog.xsd">
|
||||
<None Include="..\NzbDrone\NLog.config">
|
||||
<Link>NLog.config</Link>
|
||||
</None>
|
||||
<None Include="..\NzbDrone\NLog.xsd">
|
||||
<Link>NLog.xsd</Link>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="NzbDrone.ico" />
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||
@ -148,19 +108,16 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Api\NzbDrone.Api.csproj">
|
||||
<Project>{fd286df8-2d3a-4394-8ad5-443fade55fb2}</Project>
|
||||
<Name>NzbDrone.Api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Common\NzbDrone.Common.csproj">
|
||||
<Project>{F2BE0FDF-6E47-4827-A420-DD4EF82407F8}</Project>
|
||||
<Name>NzbDrone.Common</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NzbDrone.Core\NzbDrone.Core.csproj">
|
||||
<Project>{FF5EE3B6-913B-47CE-9CEB-11C51B4E1205}</Project>
|
||||
<Name>NzbDrone.Core</Name>
|
||||
<ProjectReference Include="..\NzbDrone\NzbDrone.csproj">
|
||||
<Project>{d12f7f2f-8a3c-415f-88fa-6dd061a84869}</Project>
|
||||
<Name>NzbDrone</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\NzbDrone\NzbDrone.ico">
|
||||
<Link>NzbDrone.ico</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
15
NzbDrone.Console/Properties/AssemblyInfo.cs
Normal file
15
NzbDrone.Console/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly: AssemblyTitle("NzbDrone.exe")]
|
||||
[assembly: Guid("67AADCD9-89AA-4D95-8281-3193740E70E5")]
|
||||
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.*")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.*")]
|
18
NzbDrone.Console/app.config
Normal file
18
NzbDrone.Console/app.config
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup useLegacyV2RuntimeActivationPolicy="true">
|
||||
<supportedRuntime version="v4.0" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Sqo;
|
||||
|
||||
@ -16,6 +17,37 @@ public interface IObjectDatabase : IDisposable
|
||||
void DeleteMany<T>(IEnumerable<T> objects) where T : ModelBase;
|
||||
}
|
||||
|
||||
public static class SiaqodbLogger
|
||||
{
|
||||
public static void ListenTo(Siaqodb db)
|
||||
{
|
||||
db.DeletedObject += OnDeletedObject;
|
||||
db.LoadingObject +=OnLoadingObject;
|
||||
db.LoadedObject +=OnLoadedObject;
|
||||
}
|
||||
|
||||
private static void OnLoadedObject(object sender, LoadedObjectEventArgs e)
|
||||
{
|
||||
Write("Loaded", e.Object.GetType(), e.OID);
|
||||
}
|
||||
|
||||
private static void OnLoadingObject(object sender, LoadingObjectEventArgs e)
|
||||
{
|
||||
Write("Loading", e.ObjectType, e.OID);
|
||||
}
|
||||
|
||||
static void OnDeletedObject(object sender, DeletedEventsArgs e)
|
||||
{
|
||||
Write("Deleted", e.ObjectType, e.OID);
|
||||
}
|
||||
|
||||
private static void Write(string operation, Type modelType, int id)
|
||||
{
|
||||
var message = string.Format("{0} {1}[{2}]", operation, modelType.Name, id);
|
||||
Trace.WriteLine(message, "Siaqodb");
|
||||
}
|
||||
}
|
||||
|
||||
public class SiaqodbProxy : IObjectDatabase
|
||||
{
|
||||
private readonly Siaqodb _db;
|
||||
@ -23,8 +55,11 @@ public class SiaqodbProxy : IObjectDatabase
|
||||
public SiaqodbProxy(Siaqodb db)
|
||||
{
|
||||
_db = db;
|
||||
//SiaqodbConfigurator.SetRaiseLoadEvents(true);
|
||||
//SiaqodbLogger.ListenTo(_db);
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@ -32,7 +67,7 @@ public void Dispose()
|
||||
|
||||
public IEnumerable<T> AsQueryable<T>()
|
||||
{
|
||||
return _db.Cast<T>();
|
||||
return _db.LoadAllLazy<T>();
|
||||
}
|
||||
|
||||
public T Insert<T>(T obj) where T : ModelBase
|
||||
|
@ -23,15 +23,7 @@ static void OnComponentPreparing(object sender, PreparingEventArgs e)
|
||||
|
||||
private static object GetLogger(Type type)
|
||||
{
|
||||
const string STRING_TO_REMOVE = "NzbDrone";
|
||||
|
||||
var loggerName = type.FullName;
|
||||
if (loggerName.StartsWith(STRING_TO_REMOVE))
|
||||
{
|
||||
loggerName = loggerName.Substring(STRING_TO_REMOVE.Length + 1);
|
||||
}
|
||||
|
||||
return LogManager.GetLogger(loggerName);
|
||||
return LogManager.GetLogger(type.Name);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
[assembly: Guid("3C29FEF7-4B07-49ED-822E-1C29DC49BFAB")]
|
||||
|
||||
[assembly: InternalsVisibleTo("NzbDrone.Core.Test")]
|
||||
[assembly: InternalsVisibleTo("NzbDrone.Web")]
|
||||
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
40
NzbDrone.sln
40
NzbDrone.sln
@ -40,8 +40,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E6B3C
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Api", "NzbDrone.Api\NzbDrone.Api.csproj", "{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Console", "NzbDrone\NzbDrone.Console.csproj", "{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0BC607C-90DC-4B3B-A2FB-7DC5B45338A4}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
JSLintOptions.xml = JSLintOptions.xml
|
||||
@ -53,6 +51,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Backbone", "NzbDro
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Integration.Mvc", "Autofac.Integration.Mvc\Autofac.Integration.Mvc.csproj", "{DD874E64-C7EC-464D-925F-CF4A709EDEEF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NzbDrone.Console", "NzbDrone.Console\NzbDrone.Console.csproj", "{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -320,24 +320,6 @@ Global
|
||||
{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Services|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Services|x64.ActiveCfg = Release|Any CPU
|
||||
{FD286DF8-2D3A-4394-8AD5-443FADE55FB2}.Services|x86.ActiveCfg = Release|Any CPU
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.Build.0 = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x64.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.Build.0 = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Any CPU.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.Build.0 = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x64.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.Build.0 = Release|x86
|
||||
{64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{64E5482F-0C4F-46C6-9377-699D3EADBA9E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
@ -389,6 +371,24 @@ Global
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|x64.ActiveCfg = Release|Any CPU
|
||||
{DD874E64-C7EC-464D-925F-CF4A709EDEEF}.Services|x86.ActiveCfg = Release|Any CPU
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x64.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Debug|x86.Build.0 = Debug|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x64.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Release|x86.Build.0 = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Any CPU.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|Mixed Platforms.Build.0 = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x64.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.ActiveCfg = Release|x86
|
||||
{3DCA7B58-B8B3-49AC-9D9E-56F4A0460976}.Services|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,18 +1,23 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using NzbDrone.Providers;
|
||||
using Autofac;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public static class AppMain
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetLogger("AppMain");
|
||||
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Starting NzbDrone Console. Version " + Assembly.GetExecutingAssembly().GetName().Version);
|
||||
logger.Info("Starting NzbDrone Console. Version {0}", Assembly.GetExecutingAssembly().GetName().Version);
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception));
|
||||
|
||||
//Check if full version .NET is installed.
|
||||
try
|
||||
@ -21,16 +26,16 @@ public static void Main(string[] args)
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("It looks like you don't have full version of .NET Framework installed. Press any key and you will be directed to the download page.");
|
||||
logger.Error("It looks like you don't have full version of .NET Framework installed. Press any key and you will be directed to the download page.");
|
||||
Console.Read();
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start("http://www.microsoft.com/download/en/details.aspx?id=17851");
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Opps. can't start default browser. Please visit http://www.microsoft.com/download/en/details.aspx?id=17851 to download .NET Framework 4.");
|
||||
logger.Warn("Oops. can't start default browser. Please visit http://www.microsoft.com/download/en/details.aspx?id=17851 to download .NET Framework 4.");
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
||||
@ -38,12 +43,18 @@ public static void Main(string[] args)
|
||||
}
|
||||
|
||||
|
||||
CentralDispatch.Container.Resolve<Router>().Route(args);
|
||||
NzbDroneBootstrapper.Container.Resolve<Router>().Route(args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MonitoringProvider.AppDomainException(e);
|
||||
}
|
||||
AppDomainException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AppDomainException(Exception exception)
|
||||
{
|
||||
Console.WriteLine("EPIC FAIL: {0}", exception);
|
||||
logger.FatalException("EPIC FAIL: " + exception.Message, exception);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
namespace NzbDrone.Model
|
||||
namespace NzbDrone
|
||||
{
|
||||
public enum ApplicationMode
|
||||
public enum ApplicationModes
|
||||
{
|
||||
Console,
|
||||
Help,
|
||||
InstallService,
|
||||
UninstallService,
|
||||
Service,
|
||||
Nancy
|
||||
}
|
||||
}
|
@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ServiceProcess;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Providers;
|
||||
|
||||
|
||||
namespace NzbDrone
|
||||
@ -17,22 +14,20 @@ public class ApplicationServer : ServiceBase
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
private readonly IHostController _hostController;
|
||||
private readonly ProcessProvider _processProvider;
|
||||
private readonly MonitoringProvider _monitoringProvider;
|
||||
private readonly PriorityMonitor _priorityMonitor;
|
||||
private readonly SecurityProvider _securityProvider;
|
||||
private readonly DiskProvider _diskProvider;
|
||||
|
||||
public ApplicationServer(ConfigFileProvider configFileProvider, IHostController hostController,
|
||||
EnvironmentProvider environmentProvider,
|
||||
ProcessProvider processProvider, MonitoringProvider monitoringProvider,
|
||||
SecurityProvider securityProvider, DiskProvider diskProvider)
|
||||
ProcessProvider processProvider, PriorityMonitor priorityMonitor,
|
||||
SecurityProvider securityProvider)
|
||||
{
|
||||
_configFileProvider = configFileProvider;
|
||||
_hostController = hostController;
|
||||
_environmentProvider = environmentProvider;
|
||||
_processProvider = processProvider;
|
||||
_monitoringProvider = monitoringProvider;
|
||||
_priorityMonitor = priorityMonitor;
|
||||
_securityProvider = securityProvider;
|
||||
_diskProvider = diskProvider;
|
||||
}
|
||||
|
||||
public ApplicationServer()
|
||||
@ -47,19 +42,9 @@ protected override void OnStart(string[] args)
|
||||
|
||||
public virtual void Start()
|
||||
{
|
||||
_hostController.StopServer();
|
||||
_securityProvider.MakeAccessible();
|
||||
|
||||
if(_securityProvider.IsCurrentUserAdmin())
|
||||
{
|
||||
var tempFiles = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "Temporary ASP.NET Files");
|
||||
logger.Debug("Creating Temporary ASP.Net folder: {0}", tempFiles);
|
||||
_diskProvider.CreateDirectory(tempFiles);
|
||||
}
|
||||
|
||||
_hostController.StartServer();
|
||||
//Todo: verify that IIS is actually started
|
||||
|
||||
|
||||
if (_environmentProvider.IsUserInteractive && _configFileProvider.LaunchBrowser)
|
||||
{
|
||||
@ -74,7 +59,7 @@ public virtual void Start()
|
||||
}
|
||||
}
|
||||
|
||||
_monitoringProvider.Start();
|
||||
_priorityMonitor.Start();
|
||||
}
|
||||
|
||||
protected override void OnStop()
|
||||
|
@ -68,6 +68,12 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Autofac.3.0.1\lib\net40\Autofac.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Exceptron.Client">
|
||||
<HintPath>..\packages\Exceptron.Client.1.0.20\lib\net20\Exceptron.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Exceptron.NLog">
|
||||
<HintPath>..\packages\Exceptron.Nlog.1.0.11\lib\net20\Exceptron.NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Nancy">
|
||||
<HintPath>..\packages\Nancy.0.16.1\lib\net40\Nancy.dll</HintPath>
|
||||
</Reference>
|
||||
@ -92,15 +98,21 @@
|
||||
<Compile Include="ApplicationServer.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CentralDispatch.cs" />
|
||||
<Compile Include="Model\ApplicationMode.cs" />
|
||||
<Compile Include="NzbDroneBootstrapper.cs" />
|
||||
<Compile Include="ApplicationMode.cs" />
|
||||
<Compile Include="AppMain.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\MonitoringProvider.cs" />
|
||||
<Compile Include="PriorityMonitor.cs" />
|
||||
<Compile Include="Router.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1,21 +0,0 @@
|
||||
<ProjectConfiguration>
|
||||
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
|
||||
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
|
||||
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
|
||||
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
|
||||
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
|
||||
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
|
||||
<RunPreBuildEvents>false</RunPreBuildEvents>
|
||||
<RunPostBuildEvents>false</RunPostBuildEvents>
|
||||
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
|
||||
<InstrumentAssembly>true</InstrumentAssembly>
|
||||
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
|
||||
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
|
||||
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
|
||||
<DefaultTestTimeout>60000</DefaultTestTimeout>
|
||||
<UseBuildConfiguration></UseBuildConfiguration>
|
||||
<UseBuildPlatform />
|
||||
<ProxyProcessPath></ProxyProcessPath>
|
||||
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
|
||||
<HiddenWarnings>PostBuildEventDisabled</HiddenWarnings>
|
||||
</ProjectConfiguration>
|
@ -7,12 +7,12 @@
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public static class CentralDispatch
|
||||
public static class NzbDroneBootstrapper
|
||||
{
|
||||
private static readonly IContainer container;
|
||||
private static readonly Logger logger = LogManager.GetLogger("Host.CentralDispatch");
|
||||
private static readonly Logger logger = LogManager.GetLogger("NzbDroneBootstrapper");
|
||||
|
||||
static CentralDispatch()
|
||||
static NzbDroneBootstrapper()
|
||||
{
|
||||
var builder = new ContainerBuilder();
|
||||
BindKernel(builder);
|
@ -1,29 +1,27 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Providers
|
||||
namespace NzbDrone
|
||||
{
|
||||
public class MonitoringProvider
|
||||
public class PriorityMonitor
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetLogger("Host.MonitoringProvider");
|
||||
|
||||
private readonly ProcessProvider _processProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
private Timer _processPriorityCheckTimer;
|
||||
|
||||
public MonitoringProvider(ProcessProvider processProvider)
|
||||
public PriorityMonitor(ProcessProvider processProvider, Logger logger)
|
||||
{
|
||||
_processProvider = processProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += ((s, e) => AppDomainException(e.ExceptionObject as Exception));
|
||||
|
||||
|
||||
_processPriorityCheckTimer = new Timer(EnsurePriority);
|
||||
_processPriorityCheckTimer.Change(TimeSpan.FromSeconds(15), TimeSpan.FromMinutes(30));
|
||||
|
||||
@ -48,14 +46,8 @@ public virtual void EnsurePriority(object sender)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.WarnException("Unable to verify priority", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AppDomainException(Exception excepion)
|
||||
{
|
||||
Console.WriteLine("EPIC FAIL: {0}", excepion);
|
||||
logger.FatalException("EPIC FAIL: " + excepion.Message, excepion);
|
||||
_logger.WarnException("Unable to verify priority", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,34 +2,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Nancy.Hosting.Self;
|
||||
using NzbDrone.Api;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.SysTray;
|
||||
using NzbDrone.Model;
|
||||
|
||||
namespace NzbDrone
|
||||
{
|
||||
public class Router
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly ApplicationServer _applicationServer;
|
||||
private readonly ServiceProvider _serviceProvider;
|
||||
private readonly ConsoleProvider _consoleProvider;
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
private readonly SysTrayProvider _sysTrayProvider;
|
||||
private readonly ProcessProvider _processProvider;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider,
|
||||
ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, ProcessProvider processProvider)
|
||||
ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, SysTrayProvider sysTrayProvider, Logger logger)
|
||||
{
|
||||
_applicationServer = applicationServer;
|
||||
_serviceProvider = serviceProvider;
|
||||
_consoleProvider = consoleProvider;
|
||||
_environmentProvider = environmentProvider;
|
||||
_sysTrayProvider = sysTrayProvider;
|
||||
_processProvider = processProvider;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Route(IEnumerable<string> args)
|
||||
@ -37,41 +32,27 @@ public void Route(IEnumerable<string> args)
|
||||
Route(GetApplicationMode(args));
|
||||
}
|
||||
|
||||
public void Route(ApplicationMode applicationMode)
|
||||
public void Route(ApplicationModes applicationModes)
|
||||
{
|
||||
if (!_environmentProvider.IsUserInteractive)
|
||||
{
|
||||
applicationMode = ApplicationMode.Service;
|
||||
applicationModes = ApplicationModes.Service;
|
||||
}
|
||||
|
||||
logger.Info("Application mode: {0}", applicationMode);
|
||||
_logger.Info("Application mode: {0}", applicationModes);
|
||||
|
||||
switch (applicationMode)
|
||||
switch (applicationModes)
|
||||
{
|
||||
case ApplicationMode.Nancy:
|
||||
case ApplicationModes.Service:
|
||||
{
|
||||
|
||||
var nancyHost = new NancyHost(new Uri("http://localhost:8282"), new NancyBootstrapper());
|
||||
nancyHost.Start();
|
||||
|
||||
|
||||
_processProvider.Start("http://localhost:8282");
|
||||
|
||||
_consoleProvider.WaitForClose();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ApplicationMode.Service:
|
||||
{
|
||||
logger.Trace("Service selected");
|
||||
_logger.Trace("Service selected");
|
||||
_serviceProvider.Run(_applicationServer);
|
||||
break;
|
||||
}
|
||||
|
||||
case ApplicationMode.Console:
|
||||
case ApplicationModes.Console:
|
||||
{
|
||||
logger.Trace("Console selected");
|
||||
_logger.Trace("Console selected");
|
||||
_applicationServer.Start();
|
||||
if (ConsoleProvider.IsConsoleApplication)
|
||||
_consoleProvider.WaitForClose();
|
||||
@ -83,9 +64,9 @@ public void Route(ApplicationMode applicationMode)
|
||||
|
||||
break;
|
||||
}
|
||||
case ApplicationMode.InstallService:
|
||||
case ApplicationModes.InstallService:
|
||||
{
|
||||
logger.Trace("Install Service selected");
|
||||
_logger.Trace("Install Service selected");
|
||||
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
_consoleProvider.PrintServiceAlreadyExist();
|
||||
@ -97,9 +78,9 @@ public void Route(ApplicationMode applicationMode)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ApplicationMode.UninstallService:
|
||||
case ApplicationModes.UninstallService:
|
||||
{
|
||||
logger.Trace("Uninstall Service selected");
|
||||
_logger.Trace("Uninstall Service selected");
|
||||
if (!_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
_consoleProvider.PrintServiceDoestExist();
|
||||
@ -119,21 +100,20 @@ public void Route(ApplicationMode applicationMode)
|
||||
}
|
||||
}
|
||||
|
||||
public static ApplicationMode GetApplicationMode(IEnumerable<string> args)
|
||||
public static ApplicationModes GetApplicationMode(IEnumerable<string> args)
|
||||
{
|
||||
if (args == null) return ApplicationMode.Console;
|
||||
if (args == null) return ApplicationModes.Console;
|
||||
|
||||
var cleanArgs = args.Where(c => c != null && !String.IsNullOrWhiteSpace(c)).ToList();
|
||||
if (cleanArgs.Count == 0) return ApplicationMode.Console;
|
||||
if (cleanArgs.Count != 1) return ApplicationMode.Help;
|
||||
if (cleanArgs.Count == 0) return ApplicationModes.Console;
|
||||
if (cleanArgs.Count != 1) return ApplicationModes.Help;
|
||||
|
||||
var arg = cleanArgs.First().Trim('/', '\\', '-').ToLower();
|
||||
|
||||
if (arg == "i") return ApplicationMode.InstallService;
|
||||
if (arg == "u") return ApplicationMode.UninstallService;
|
||||
if (arg == "n") return ApplicationMode.Nancy;
|
||||
if (arg == "i") return ApplicationModes.InstallService;
|
||||
if (arg == "u") return ApplicationModes.UninstallService;
|
||||
|
||||
return ApplicationMode.Help;
|
||||
return ApplicationModes.Help;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user