From 6b7923bd528d02a0d7c3249036f28d1df95452ee Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Wed, 12 Oct 2011 19:24:30 -0700 Subject: [PATCH 1/4] Windows service is half working, --- NzbDrone.App.Test/CentralDispatchTests.cs | 17 ++++++----- NzbDrone.App.Test/NzbDrone.App.Test.csproj | 4 ++- NzbDrone.App.Test/ServiceControllerTests.cs | 11 +++++++ NzbDrone.App.Test/packages.config | 1 + NzbDrone/CentralDispatch.cs | 4 +++ NzbDrone/NzbDrone.csproj | 3 ++ NzbDrone/NzbDroneConsole.cs | 9 +++--- NzbDrone/NzbDroneService.cs | 33 ++++++++++++++++++--- NzbDrone/Providers/ConsoleProvider.cs | 8 +++-- NzbDrone/Providers/EnviromentProvider.cs | 12 ++++++-- NzbDrone/Providers/ServiceProvider.cs | 4 ++- NzbDrone/Router.cs | 9 ++++-- 12 files changed, 92 insertions(+), 23 deletions(-) diff --git a/NzbDrone.App.Test/CentralDispatchTests.cs b/NzbDrone.App.Test/CentralDispatchTests.cs index 67d1790c8..7cf1d74db 100644 --- a/NzbDrone.App.Test/CentralDispatchTests.cs +++ b/NzbDrone.App.Test/CentralDispatchTests.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using Ninject; -using NzbDrone.Providers; namespace NzbDrone.App.Test { @@ -36,5 +30,14 @@ namespace NzbDrone.App.Test appServer.Should().NotBeNull(); } + [Test] + public void Kernel_should_resolve_same_ApplicationServer_instance() + { + var appServer1 = CentralDispatch.Kernel.Get(); + var appServer2 = CentralDispatch.Kernel.Get(); + + appServer1.Should().BeSameAs(appServer2); + } + } } diff --git a/NzbDrone.App.Test/NzbDrone.App.Test.csproj b/NzbDrone.App.Test/NzbDrone.App.Test.csproj index fe0aa62d4..32ddcc403 100644 --- a/NzbDrone.App.Test/NzbDrone.App.Test.csproj +++ b/NzbDrone.App.Test/NzbDrone.App.Test.csproj @@ -50,7 +50,9 @@ ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll - + + ..\packages\Ninject.2.2.1.4\lib\net40-Full\Ninject.dll + ..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll diff --git a/NzbDrone.App.Test/ServiceControllerTests.cs b/NzbDrone.App.Test/ServiceControllerTests.cs index 9fcc1b33a..00534788d 100644 --- a/NzbDrone.App.Test/ServiceControllerTests.cs +++ b/NzbDrone.App.Test/ServiceControllerTests.cs @@ -46,5 +46,16 @@ namespace NzbDrone.App.Test serviceController.UnInstall(); serviceController.ServiceExist(ServiceProvider.NzbDroneServiceName).Should().BeFalse(); } + + [Test] + [Explicit] + public void UnInstallService() + { + var serviceController = new ServiceProvider(); + + //Act + serviceController.UnInstall(); + serviceController.ServiceExist(ServiceProvider.NzbDroneServiceName).Should().BeFalse(); + } } } diff --git a/NzbDrone.App.Test/packages.config b/NzbDrone.App.Test/packages.config index 0132851a6..d52a9cd18 100644 --- a/NzbDrone.App.Test/packages.config +++ b/NzbDrone.App.Test/packages.config @@ -4,6 +4,7 @@ + \ No newline at end of file diff --git a/NzbDrone/CentralDispatch.cs b/NzbDrone/CentralDispatch.cs index bc2df874f..10b96c2c2 100644 --- a/NzbDrone/CentralDispatch.cs +++ b/NzbDrone/CentralDispatch.cs @@ -18,6 +18,8 @@ namespace NzbDrone static CentralDispatch() { _kernel = new StandardKernel(); + BindKernel(); + InitilizeApp(); } public static ApplicationMode ApplicationMode { get; set; } @@ -33,6 +35,7 @@ namespace NzbDrone private static void BindKernel() { _kernel = new StandardKernel(); + _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); @@ -42,6 +45,7 @@ namespace NzbDrone _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); + } private static void InitilizeApp() diff --git a/NzbDrone/NzbDrone.csproj b/NzbDrone/NzbDrone.csproj index 329dde2c8..62dc61b76 100644 --- a/NzbDrone/NzbDrone.csproj +++ b/NzbDrone/NzbDrone.csproj @@ -53,6 +53,9 @@ NzbDrone.ico + + NzbDrone.NzbDroneConsole + True diff --git a/NzbDrone/NzbDroneConsole.cs b/NzbDrone/NzbDroneConsole.cs index a0f6f1422..f067a09b0 100644 --- a/NzbDrone/NzbDroneConsole.cs +++ b/NzbDrone/NzbDroneConsole.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; +using System.Threading; using NLog; using Ninject; using NzbDrone.Model; @@ -14,10 +16,12 @@ namespace NzbDrone private static readonly Logger Logger = LogManager.GetLogger("Host.Main"); - private static void Main(string[] args) + public static void Main(string[] args) { try { + //while (!Debugger.IsAttached) Thread.Sleep(100); + Console.WriteLine("Starting NzbDrone Console. Version " + Assembly.GetExecutingAssembly().GetName().Version); CentralDispatch.ApplicationMode = GetApplicationMode(args); @@ -29,9 +33,6 @@ namespace NzbDrone Console.WriteLine(e.ToString()); Logger.Fatal(e.ToString()); } - - Console.WriteLine("Press enter to exit."); - Console.ReadLine(); } public static ApplicationMode GetApplicationMode(IEnumerable args) diff --git a/NzbDrone/NzbDroneService.cs b/NzbDrone/NzbDroneService.cs index c2d41b092..c7394bd53 100644 --- a/NzbDrone/NzbDroneService.cs +++ b/NzbDrone/NzbDroneService.cs @@ -1,18 +1,43 @@ -using System.ServiceProcess; +using System; +using System.Diagnostics; +using System.ServiceProcess; +using System.Threading; +using NLog; using Ninject; namespace NzbDrone { - internal class NzbDroneService : ServiceBase + public class NzbDroneService : ServiceBase { + + private static readonly Logger Logger = LogManager.GetLogger("Host.CentralDispatch"); + protected override void OnStart(string[] args) { - CentralDispatch.Kernel.Get().Start(); + try + { + while (!Debugger.IsAttached) Thread.Sleep(100); + Debugger.Break(); + CentralDispatch.Kernel.Get().Start(); + } + catch (Exception e) + { + + Logger.Fatal("Failed to start Windows Service", e); + } + } protected override void OnStop() { - CentralDispatch.Kernel.Get().Stop(); + try + { + CentralDispatch.Kernel.Get().Stop(); + } + catch (Exception e) + { + Logger.Fatal("Failed to stop Windows Service", e); + } } } } \ No newline at end of file diff --git a/NzbDrone/Providers/ConsoleProvider.cs b/NzbDrone/Providers/ConsoleProvider.cs index e5b98643d..915f084a3 100644 --- a/NzbDrone/Providers/ConsoleProvider.cs +++ b/NzbDrone/Providers/ConsoleProvider.cs @@ -1,20 +1,24 @@ using System; +using NLog; namespace NzbDrone.Providers { public class ConsoleProvider { + private static readonly Logger Logger = LogManager.GetLogger("Host.ConsoleProvider"); + public virtual void WaitForClose() { while (true) { - System.Console.ReadLine(); + Console.ReadLine(); } } public virtual void PrintHelp() { - System.Console.WriteLine("Help"); + Logger.Info("Printing Help"); + Console.WriteLine("Help"); } } } \ No newline at end of file diff --git a/NzbDrone/Providers/EnviromentProvider.cs b/NzbDrone/Providers/EnviromentProvider.cs index 2659806bc..8e046029b 100644 --- a/NzbDrone/Providers/EnviromentProvider.cs +++ b/NzbDrone/Providers/EnviromentProvider.cs @@ -20,14 +20,22 @@ namespace NzbDrone.Providers { get { - var dir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory; + var dir = new FileInfo(Environment.CurrentDirectory).Directory; while (dir.GetDirectories("iisexpress").Length == 0) { - if (dir.Parent == null) throw new ApplicationException("Can't fine IISExpress folder."); + if (dir.Parent == null) break; dir = dir.Parent; } + dir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory; + + while (dir.GetDirectories("iisexpress").Length == 0) + { + if (dir.Parent == null) throw new ApplicationException("Can't fine IISExpress folder."); + dir = dir.Parent; + } + return dir.FullName; } } diff --git a/NzbDrone/Providers/ServiceProvider.cs b/NzbDrone/Providers/ServiceProvider.cs index 63d54bb2f..240cfa797 100644 --- a/NzbDrone/Providers/ServiceProvider.cs +++ b/NzbDrone/Providers/ServiceProvider.cs @@ -43,6 +43,8 @@ namespace NzbDrone.Providers serviceInstaller.DisplayName = NzbDroneServiceName; serviceInstaller.ServiceName = NzbDroneServiceName; serviceInstaller.StartType = ServiceStartMode.Automatic; + + serviceInstaller.Parent = installer; serviceInstaller.Install(new ListDictionary()); @@ -54,7 +56,7 @@ namespace NzbDrone.Providers { var serviceInstaller = new ServiceInstaller(); - var context = new InstallContext("install.log", null); + var context = new InstallContext("service_uninstall.log", null); serviceInstaller.Context = context; serviceInstaller.ServiceName = NzbDroneServiceName; serviceInstaller.Uninstall(null); diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs index bb1065bc5..afda37861 100644 --- a/NzbDrone/Router.cs +++ b/NzbDrone/Router.cs @@ -2,13 +2,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using NLog; using NzbDrone.Model; using NzbDrone.Providers; namespace NzbDrone { - class Router + public class Router { + private static readonly Logger Logger = LogManager.GetLogger("Host.Router"); + private readonly ApplicationServer _applicationServer; private readonly ServiceProvider _serviceProvider; private readonly ConsoleProvider _consoleProvider; @@ -17,13 +20,15 @@ namespace NzbDrone { _applicationServer = applicationServer; _serviceProvider = serviceProvider; - _consoleProvider = consoleProvider; + _consoleProvider = consoleProvider; } public void Route() { + Logger.Info("Application mode: {0}", CentralDispatch.ApplicationMode); switch (CentralDispatch.ApplicationMode) { + case ApplicationMode.Console: { _applicationServer.Start(); From 6f3065d5ab4094e00bbc58ff637adbcf528491d4 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 13 Oct 2011 18:22:51 -0700 Subject: [PATCH 2/4] More work on WindowsService, still broken --- NzbDrone.App.Test/NzbDrone.App.Test.csproj | 2 +- NzbDrone.App.Test/ProgramTest.cs | 43 -------- NzbDrone.App.Test/RouterTest.cs | 121 +++++++++++++++++++++ NzbDrone/AppMain.cs | 36 ++++++ NzbDrone/ApplicationServer.cs | 24 +++- NzbDrone/CentralDispatch.cs | 2 - NzbDrone/NzbDrone.csproj | 11 +- NzbDrone/NzbDroneConsole.cs | 54 --------- NzbDrone/NzbDroneService.cs | 43 -------- NzbDrone/Providers/ConsoleProvider.cs | 5 + NzbDrone/Providers/EnviromentProvider.cs | 20 +++- NzbDrone/Providers/ServiceProvider.cs | 10 +- NzbDrone/Router.cs | 99 ++++++++++++----- 13 files changed, 288 insertions(+), 182 deletions(-) delete mode 100644 NzbDrone.App.Test/ProgramTest.cs create mode 100644 NzbDrone.App.Test/RouterTest.cs create mode 100644 NzbDrone/AppMain.cs delete mode 100644 NzbDrone/NzbDroneConsole.cs delete mode 100644 NzbDrone/NzbDroneService.cs diff --git a/NzbDrone.App.Test/NzbDrone.App.Test.csproj b/NzbDrone.App.Test/NzbDrone.App.Test.csproj index 32ddcc403..84d8ce7d7 100644 --- a/NzbDrone.App.Test/NzbDrone.App.Test.csproj +++ b/NzbDrone.App.Test/NzbDrone.App.Test.csproj @@ -77,7 +77,7 @@ - + diff --git a/NzbDrone.App.Test/ProgramTest.cs b/NzbDrone.App.Test/ProgramTest.cs deleted file mode 100644 index 464fad9d4..000000000 --- a/NzbDrone.App.Test/ProgramTest.cs +++ /dev/null @@ -1,43 +0,0 @@ -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Model; -using NzbDrone.Providers; - -namespace NzbDrone.App.Test -{ - [TestFixture] - public class ProgramTest - { - - [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) - { - NzbDroneConsole.GetApplicationMode(new[] { arg }).Should().Be(mode); - } - - [TestCase("", "", ApplicationMode.Console)] - [TestCase("", null, ApplicationMode.Console)] - [TestCase("i", "n", ApplicationMode.Help)] - public void GetApplicationMode_two_args(string a, string b, ApplicationMode mode) - { - NzbDroneConsole.GetApplicationMode(new[] { a, b }).Should().Be(mode); - } - } -} diff --git a/NzbDrone.App.Test/RouterTest.cs b/NzbDrone.App.Test/RouterTest.cs new file mode 100644 index 000000000..e4f45028b --- /dev/null +++ b/NzbDrone.App.Test/RouterTest.cs @@ -0,0 +1,121 @@ +using AutoMoq; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Model; +using NzbDrone.Providers; + +namespace NzbDrone.App.Test +{ + [TestFixture] + public class RouterTest + { + + [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) + { + Router.GetApplicationMode(new[] { arg }).Should().Be(mode); + } + + [TestCase("", "", ApplicationMode.Console)] + [TestCase("", null, ApplicationMode.Console)] + [TestCase("i", "n", ApplicationMode.Help)] + public void GetApplicationMode_two_args(string a, string b, ApplicationMode mode) + { + Router.GetApplicationMode(new[] { a, b }).Should().Be(mode); + } + + [Test] + public void Route_should_call_install_service_when_application_mode_is_install() + { + var mocker = new AutoMoqer(MockBehavior.Strict); + var serviceProviderMock = mocker.GetMock(); + serviceProviderMock.Setup(c => c.Install()); + mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + + mocker.Resolve().Route(ApplicationMode.InstallService); + + serviceProviderMock.Verify(c => c.Install(), Times.Once()); + } + + [Test] + public void Route_should_call_uninstall_service_when_application_mode_is_uninstall() + { + var mocker = new AutoMoqer(MockBehavior.Strict); + var serviceProviderMock = mocker.GetMock(); + serviceProviderMock.Setup(c => c.UnInstall()); + mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + + mocker.Resolve().Route(ApplicationMode.UninstallService); + + serviceProviderMock.Verify(c => c.UnInstall(), Times.Once()); + } + + [Test] + public void Route_should_call_console_service_when_application_mode_is_console() + { + var mocker = new AutoMoqer(MockBehavior.Strict); + var consoleProvider = mocker.GetMock(); + var appServerProvider = mocker.GetMock(); + consoleProvider.Setup(c => c.WaitForClose()); + appServerProvider.Setup(c => c.Start()); + mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + + mocker.Resolve().Route(ApplicationMode.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) + { + var mocker = new AutoMoqer(MockBehavior.Strict); + var envMock = mocker.GetMock(); + var appServerMock = mocker.GetMock(); + + envMock.SetupGet(c => c.IsRunningAsService).Returns(true); + appServerMock.Setup(c => c.StartService()); + + mocker.Resolve().Route(applicationMode); + + appServerMock.Verify(c => c.StartService(), Times.Once()); + } + + + [Test] + public void show_error_on_install_if_service_already_exist() + { + var mocker = new AutoMoqer(MockBehavior.Strict); + var consoleMock = mocker.GetMock(); + var serviceMock = mocker.GetMock(); + mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + + consoleMock.Setup(c => c.PrintServiceAlreadyExist()); + serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NzbDroneServiceName)).Returns(true); + + mocker.Resolve().Route(ApplicationMode.InstallService); + + mocker.VerifyAllMocks(); + } + } +} diff --git a/NzbDrone/AppMain.cs b/NzbDrone/AppMain.cs new file mode 100644 index 000000000..3960d8929 --- /dev/null +++ b/NzbDrone/AppMain.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Threading; +using NLog; +using Ninject; +using NzbDrone.Model; + +namespace NzbDrone +{ + public static class AppMain + { + + + private static readonly Logger Logger = LogManager.GetLogger("Host.Main"); + + public static void Main(string[] args) + { + try + { + Console.WriteLine("Starting NzbDrone Console. Version " + Assembly.GetExecutingAssembly().GetName().Version); + + CentralDispatch.Kernel.Get().Route(args); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + Logger.Fatal(e.ToString()); + } + } + + + } +} \ No newline at end of file diff --git a/NzbDrone/ApplicationServer.cs b/NzbDrone/ApplicationServer.cs index 41665b52d..f3f1c6bda 100644 --- a/NzbDrone/ApplicationServer.cs +++ b/NzbDrone/ApplicationServer.cs @@ -1,5 +1,6 @@ using System; using System.Net; +using System.ServiceProcess; using System.Threading; using NLog; using Ninject; @@ -7,7 +8,7 @@ using NzbDrone.Providers; namespace NzbDrone { - public class ApplicationServer + public class ApplicationServer : ServiceBase { private static readonly Logger Logger = LogManager.GetLogger("Host.App"); @@ -18,6 +19,13 @@ namespace NzbDrone private readonly ProcessProvider _processProvider; private readonly WebClient _webClient; + public void IsRunningAsService() + { + Logger.Warn(base.Container); + Logger.Warn(base.ServiceName); + + } + [Inject] public ApplicationServer(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider, DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider, @@ -33,6 +41,13 @@ namespace NzbDrone public ApplicationServer() { + + } + + public virtual void StartService() + { + Start(); + Run(this); } public virtual void Start() @@ -67,7 +82,12 @@ namespace NzbDrone } } - public virtual void Stop() + protected override void OnStop() + { + StopServer(); + } + + public void StopServer() { Logger.Info("Attempting to stop application."); _iisProvider.StopServer(); diff --git a/NzbDrone/CentralDispatch.cs b/NzbDrone/CentralDispatch.cs index 10b96c2c2..21513e626 100644 --- a/NzbDrone/CentralDispatch.cs +++ b/NzbDrone/CentralDispatch.cs @@ -22,8 +22,6 @@ namespace NzbDrone InitilizeApp(); } - public static ApplicationMode ApplicationMode { get; set; } - public static StandardKernel Kernel { get diff --git a/NzbDrone/NzbDrone.csproj b/NzbDrone/NzbDrone.csproj index 62dc61b76..e9dfb5e0e 100644 --- a/NzbDrone/NzbDrone.csproj +++ b/NzbDrone/NzbDrone.csproj @@ -54,7 +54,7 @@ NzbDrone.ico - NzbDrone.NzbDroneConsole + NzbDrone.AppMain @@ -88,7 +88,9 @@ - + + Component + @@ -96,13 +98,10 @@ - - Component - - + diff --git a/NzbDrone/NzbDroneConsole.cs b/NzbDrone/NzbDroneConsole.cs deleted file mode 100644 index f067a09b0..000000000 --- a/NzbDrone/NzbDroneConsole.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Threading; -using NLog; -using Ninject; -using NzbDrone.Model; - -namespace NzbDrone -{ - public static class NzbDroneConsole - { - - - private static readonly Logger Logger = LogManager.GetLogger("Host.Main"); - - public static void Main(string[] args) - { - try - { - //while (!Debugger.IsAttached) Thread.Sleep(100); - - Console.WriteLine("Starting NzbDrone Console. Version " + Assembly.GetExecutingAssembly().GetName().Version); - - CentralDispatch.ApplicationMode = GetApplicationMode(args); - - CentralDispatch.Kernel.Get().Route(); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - Logger.Fatal(e.ToString()); - } - } - - public static ApplicationMode GetApplicationMode(IEnumerable args) - { - if (args == null) return ApplicationMode.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; - - var arg = cleanArgs.First().Trim('/', '\\', '-').ToLower(); - - if (arg == "i") return ApplicationMode.InstallService; - if (arg == "u") return ApplicationMode.UninstallService; - - return ApplicationMode.Help; - } - } -} \ No newline at end of file diff --git a/NzbDrone/NzbDroneService.cs b/NzbDrone/NzbDroneService.cs deleted file mode 100644 index c7394bd53..000000000 --- a/NzbDrone/NzbDroneService.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Diagnostics; -using System.ServiceProcess; -using System.Threading; -using NLog; -using Ninject; - -namespace NzbDrone -{ - public class NzbDroneService : ServiceBase - { - - private static readonly Logger Logger = LogManager.GetLogger("Host.CentralDispatch"); - - protected override void OnStart(string[] args) - { - try - { - while (!Debugger.IsAttached) Thread.Sleep(100); - Debugger.Break(); - CentralDispatch.Kernel.Get().Start(); - } - catch (Exception e) - { - - Logger.Fatal("Failed to start Windows Service", e); - } - - } - - protected override void OnStop() - { - try - { - CentralDispatch.Kernel.Get().Stop(); - } - catch (Exception e) - { - Logger.Fatal("Failed to stop Windows Service", e); - } - } - } -} \ No newline at end of file diff --git a/NzbDrone/Providers/ConsoleProvider.cs b/NzbDrone/Providers/ConsoleProvider.cs index 915f084a3..c4374363b 100644 --- a/NzbDrone/Providers/ConsoleProvider.cs +++ b/NzbDrone/Providers/ConsoleProvider.cs @@ -20,5 +20,10 @@ namespace NzbDrone.Providers Logger.Info("Printing Help"); Console.WriteLine("Help"); } + + public virtual void PrintServiceAlreadyExist() + { + Console.WriteLine("A service with the same name ({0}) already exists. Aborting installation", ServiceProvider.NzbDroneServiceName); + } } } \ No newline at end of file diff --git a/NzbDrone/Providers/EnviromentProvider.cs b/NzbDrone/Providers/EnviromentProvider.cs index 8e046029b..b12fff7b3 100644 --- a/NzbDrone/Providers/EnviromentProvider.cs +++ b/NzbDrone/Providers/EnviromentProvider.cs @@ -16,6 +16,22 @@ namespace NzbDrone.Providers get { return Environment.UserInteractive; } } + public virtual bool IsRunningAsService + { + get + { + try + { + Console.Write(""); + return false; + } + catch (Exception) + { + return true; + } + } + } + public virtual string ApplicationPath { get @@ -29,13 +45,13 @@ namespace NzbDrone.Providers } dir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory; - + while (dir.GetDirectories("iisexpress").Length == 0) { if (dir.Parent == null) throw new ApplicationException("Can't fine IISExpress folder."); dir = dir.Parent; } - + return dir.FullName; } } diff --git a/NzbDrone/Providers/ServiceProvider.cs b/NzbDrone/Providers/ServiceProvider.cs index 240cfa797..99c00140d 100644 --- a/NzbDrone/Providers/ServiceProvider.cs +++ b/NzbDrone/Providers/ServiceProvider.cs @@ -15,7 +15,9 @@ namespace NzbDrone.Providers private static readonly Logger Logger = LogManager.GetLogger("Host.ServiceManager"); - public bool ServiceExist(string name) + + + public virtual bool ServiceExist(string name) { return ServiceController.GetServices().Any( @@ -36,15 +38,15 @@ namespace NzbDrone.Providers var serviceInstaller = new ServiceInstaller(); - String[] cmdline = {@"/assemblypath=" + Assembly.GetExecutingAssembly().Location}; + String[] cmdline = { @"/assemblypath=" + Assembly.GetExecutingAssembly().Location }; var context = new InstallContext("service_install.log", cmdline); serviceInstaller.Context = context; serviceInstaller.DisplayName = NzbDroneServiceName; serviceInstaller.ServiceName = NzbDroneServiceName; serviceInstaller.StartType = ServiceStartMode.Automatic; - - + + serviceInstaller.Parent = installer; serviceInstaller.Install(new ListDictionary()); diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs index afda37861..7eba497b0 100644 --- a/NzbDrone/Router.cs +++ b/NzbDrone/Router.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; +using System.Threading; using NLog; using NzbDrone.Model; using NzbDrone.Providers; @@ -15,42 +17,89 @@ namespace NzbDrone private readonly ApplicationServer _applicationServer; private readonly ServiceProvider _serviceProvider; private readonly ConsoleProvider _consoleProvider; + private readonly EnviromentProvider _enviromentProvider; - public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, ConsoleProvider consoleProvider) + public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, ConsoleProvider consoleProvider, EnviromentProvider enviromentProvider) { _applicationServer = applicationServer; _serviceProvider = serviceProvider; _consoleProvider = consoleProvider; + _enviromentProvider = enviromentProvider; } - public void Route() + public void Route(IEnumerable args) { - Logger.Info("Application mode: {0}", CentralDispatch.ApplicationMode); - switch (CentralDispatch.ApplicationMode) + Route(GetApplicationMode(args)); + } + + public void Route(ApplicationMode applicationMode) + { + Logger.Info("Application mode: {0}", applicationMode); + + _applicationServer.IsRunningAsService(); + + while (!Debugger.IsAttached) { + Thread.Sleep(1000); + } + + + if (_enviromentProvider.IsRunningAsService) + { + _applicationServer.StartService(); - case ApplicationMode.Console: - { - _applicationServer.Start(); - _consoleProvider.WaitForClose(); - break; - } - case ApplicationMode.InstallService: - { - _serviceProvider.Install(); - break; - } - case ApplicationMode.UninstallService: - { - _serviceProvider.UnInstall(); - break; - } - default: - { - _consoleProvider.PrintHelp(); - break; - } } + else + { + switch (applicationMode) + { + + case ApplicationMode.Console: + { + _applicationServer.Start(); + _consoleProvider.WaitForClose(); + break; + } + case ApplicationMode.InstallService: + { + if (_serviceProvider.ServiceExist(ServiceProvider.NzbDroneServiceName)) + { + _consoleProvider.PrintServiceAlreadyExist(); + } + else + { + _serviceProvider.Install(); + } + break; + } + case ApplicationMode.UninstallService: + { + _serviceProvider.UnInstall(); + break; + } + default: + { + _consoleProvider.PrintHelp(); + break; + } + } + } + } + + public static ApplicationMode GetApplicationMode(IEnumerable args) + { + if (args == null) return ApplicationMode.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; + + var arg = cleanArgs.First().Trim('/', '\\', '-').ToLower(); + + if (arg == "i") return ApplicationMode.InstallService; + if (arg == "u") return ApplicationMode.UninstallService; + + return ApplicationMode.Help; } } } From e90a3ae9de7dd12b5a924d0336cdd3b6375795cb Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Fri, 14 Oct 2011 17:41:09 -0700 Subject: [PATCH 3/4] Windows service seems to be fully working. --- NzbDrone.App.Test/RouterTest.cs | 39 ++++++++++++++++----- NzbDrone.App.Test/ServiceControllerTests.cs | 2 +- NzbDrone.Web/log.config | 2 +- NzbDrone/ApplicationServer.cs | 23 +++++------- NzbDrone/CentralDispatch.cs | 2 +- NzbDrone/Providers/ConsoleProvider.cs | 17 ++++++--- NzbDrone/Providers/EnviromentProvider.cs | 27 +++++--------- NzbDrone/Providers/ServiceProvider.cs | 12 +++++-- NzbDrone/Router.cs | 23 ++++++------ 9 files changed, 83 insertions(+), 64 deletions(-) diff --git a/NzbDrone.App.Test/RouterTest.cs b/NzbDrone.App.Test/RouterTest.cs index e4f45028b..264277990 100644 --- a/NzbDrone.App.Test/RouterTest.cs +++ b/NzbDrone.App.Test/RouterTest.cs @@ -1,4 +1,5 @@ -using AutoMoq; +using System.ServiceProcess; +using AutoMoq; using FluentAssertions; using Moq; using NUnit.Framework; @@ -47,20 +48,23 @@ namespace NzbDrone.App.Test var mocker = new AutoMoqer(MockBehavior.Strict); var serviceProviderMock = mocker.GetMock(); serviceProviderMock.Setup(c => c.Install()); - mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NzbDroneServiceName)).Returns(false); + mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); mocker.Resolve().Route(ApplicationMode.InstallService); serviceProviderMock.Verify(c => c.Install(), Times.Once()); } + [Test] public void Route_should_call_uninstall_service_when_application_mode_is_uninstall() { var mocker = new AutoMoqer(MockBehavior.Strict); var serviceProviderMock = mocker.GetMock(); serviceProviderMock.Setup(c => c.UnInstall()); - mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); + serviceProviderMock.Setup(c => c.ServiceExist(ServiceProvider.NzbDroneServiceName)).Returns(true); mocker.Resolve().Route(ApplicationMode.UninstallService); @@ -75,7 +79,7 @@ namespace NzbDrone.App.Test var appServerProvider = mocker.GetMock(); consoleProvider.Setup(c => c.WaitForClose()); appServerProvider.Setup(c => c.Start()); - mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); mocker.Resolve().Route(ApplicationMode.Console); @@ -91,14 +95,15 @@ namespace NzbDrone.App.Test { var mocker = new AutoMoqer(MockBehavior.Strict); var envMock = mocker.GetMock(); - var appServerMock = mocker.GetMock(); + var serviceProvider = mocker.GetMock(); - envMock.SetupGet(c => c.IsRunningAsService).Returns(true); - appServerMock.Setup(c => c.StartService()); + envMock.SetupGet(c => c.IsUserInteractive).Returns(false); + + serviceProvider.Setup(c => c.Run(It.IsAny())); mocker.Resolve().Route(applicationMode); - appServerMock.Verify(c => c.StartService(), Times.Once()); + serviceProvider.Verify(c => c.Run(It.IsAny()), Times.Once()); } @@ -108,7 +113,7 @@ namespace NzbDrone.App.Test var mocker = new AutoMoqer(MockBehavior.Strict); var consoleMock = mocker.GetMock(); var serviceMock = mocker.GetMock(); - mocker.GetMock().SetupGet(c => c.IsRunningAsService).Returns(false); + mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); consoleMock.Setup(c => c.PrintServiceAlreadyExist()); serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NzbDroneServiceName)).Returns(true); @@ -117,5 +122,21 @@ namespace NzbDrone.App.Test mocker.VerifyAllMocks(); } + + [Test] + public void show_error_on_uninstall_if_service_doesnt_exist() + { + var mocker = new AutoMoqer(MockBehavior.Strict); + var consoleMock = mocker.GetMock(); + var serviceMock = mocker.GetMock(); + mocker.GetMock().SetupGet(c => c.IsUserInteractive).Returns(true); + + consoleMock.Setup(c => c.PrintServiceDoestExist()); + serviceMock.Setup(c => c.ServiceExist(ServiceProvider.NzbDroneServiceName)).Returns(false); + + mocker.Resolve().Route(ApplicationMode.UninstallService); + + mocker.VerifyAllMocks(); + } } } diff --git a/NzbDrone.App.Test/ServiceControllerTests.cs b/NzbDrone.App.Test/ServiceControllerTests.cs index 00534788d..05cab1154 100644 --- a/NzbDrone.App.Test/ServiceControllerTests.cs +++ b/NzbDrone.App.Test/ServiceControllerTests.cs @@ -40,7 +40,7 @@ namespace NzbDrone.App.Test var serviceController = new ServiceProvider(); //Act - serviceController.ServiceExist(ServiceProvider.NzbDroneServiceName).Should().BeFalse(); + serviceController.ServiceExist(ServiceProvider.NzbDroneServiceName).Should().BeFalse("Service already installed"); serviceController.Install(); serviceController.ServiceExist(ServiceProvider.NzbDroneServiceName).Should().BeTrue(); serviceController.UnInstall(); diff --git a/NzbDrone.Web/log.config b/NzbDrone.Web/log.config index 3e9e0b3a6..e1a578687 100644 --- a/NzbDrone.Web/log.config +++ b/NzbDrone.Web/log.config @@ -1,6 +1,6 @@  - + diff --git a/NzbDrone/ApplicationServer.cs b/NzbDrone/ApplicationServer.cs index f3f1c6bda..8cb093b15 100644 --- a/NzbDrone/ApplicationServer.cs +++ b/NzbDrone/ApplicationServer.cs @@ -1,5 +1,7 @@ using System; +using System.Diagnostics; using System.Net; +using System.Reflection; using System.ServiceProcess; using System.Threading; using NLog; @@ -17,19 +19,13 @@ namespace NzbDrone private readonly EnviromentProvider _enviromentProvider; private readonly IISProvider _iisProvider; private readonly ProcessProvider _processProvider; + private readonly MonitoringProvider _monitoringProvider; private readonly WebClient _webClient; - public void IsRunningAsService() - { - Logger.Warn(base.Container); - Logger.Warn(base.ServiceName); - - } - [Inject] public ApplicationServer(ConfigProvider configProvider, WebClient webClient, IISProvider iisProvider, DebuggerProvider debuggerProvider, EnviromentProvider enviromentProvider, - ProcessProvider processProvider) + ProcessProvider processProvider, MonitoringProvider monitoringProvider) { _configProvider = configProvider; _webClient = webClient; @@ -37,6 +33,7 @@ namespace NzbDrone _debuggerProvider = debuggerProvider; _enviromentProvider = enviromentProvider; _processProvider = processProvider; + _monitoringProvider = monitoringProvider; } public ApplicationServer() @@ -44,10 +41,9 @@ namespace NzbDrone } - public virtual void StartService() + protected override void OnStart(string[] args) { Start(); - Run(this); } public virtual void Start() @@ -80,14 +76,11 @@ namespace NzbDrone Logger.ErrorException("Failed to load home page.", e); } } - } - protected override void OnStop() - { - StopServer(); + _monitoringProvider.Start(); } - public void StopServer() + protected override void OnStop() { Logger.Info("Attempting to stop application."); _iisProvider.StopServer(); diff --git a/NzbDrone/CentralDispatch.cs b/NzbDrone/CentralDispatch.cs index 21513e626..6c4944f4e 100644 --- a/NzbDrone/CentralDispatch.cs +++ b/NzbDrone/CentralDispatch.cs @@ -50,7 +50,7 @@ namespace NzbDrone { _kernel.Get().ConfigureNlog(); _kernel.Get().CreateDefaultConfigFile(); - Logger.Info("Starting NZBDrone. Start-up Path:'{0}'", _kernel.Get().ApplicationPath); + Logger.Info("Start-up Path:'{0}'", _kernel.Get().ApplicationPath); Thread.CurrentThread.Name = "Host"; } } diff --git a/NzbDrone/Providers/ConsoleProvider.cs b/NzbDrone/Providers/ConsoleProvider.cs index c4374363b..e2281e905 100644 --- a/NzbDrone/Providers/ConsoleProvider.cs +++ b/NzbDrone/Providers/ConsoleProvider.cs @@ -1,12 +1,12 @@ using System; +using System.Diagnostics; +using System.Reflection; using NLog; namespace NzbDrone.Providers { public class ConsoleProvider { - private static readonly Logger Logger = LogManager.GetLogger("Host.ConsoleProvider"); - public virtual void WaitForClose() { while (true) @@ -17,13 +17,22 @@ namespace NzbDrone.Providers public virtual void PrintHelp() { - Logger.Info("Printing Help"); - Console.WriteLine("Help"); + Console.WriteLine(); + Console.WriteLine(" Usage: {0} ", Process.GetCurrentProcess().MainModule.ModuleName); + Console.WriteLine(" Commands:"); + Console.WriteLine(" /i Install the application as a Windows Service ({0}).", ServiceProvider.NzbDroneServiceName); + Console.WriteLine(" /u Uninstall already installed Windows Service ({0}).", ServiceProvider.NzbDroneServiceName); + Console.WriteLine(" Run application in console mode."); } public virtual void PrintServiceAlreadyExist() { Console.WriteLine("A service with the same name ({0}) already exists. Aborting installation", ServiceProvider.NzbDroneServiceName); } + + public virtual void PrintServiceDoestExist() + { + Console.WriteLine("Can't find service ({0})", ServiceProvider.NzbDroneServiceName); + } } } \ No newline at end of file diff --git a/NzbDrone/Providers/EnviromentProvider.cs b/NzbDrone/Providers/EnviromentProvider.cs index b12fff7b3..3373d37ae 100644 --- a/NzbDrone/Providers/EnviromentProvider.cs +++ b/NzbDrone/Providers/EnviromentProvider.cs @@ -16,37 +16,23 @@ namespace NzbDrone.Providers get { return Environment.UserInteractive; } } - public virtual bool IsRunningAsService - { - get - { - try - { - Console.Write(""); - return false; - } - catch (Exception) - { - return true; - } - } - } - public virtual string ApplicationPath { get { var dir = new FileInfo(Environment.CurrentDirectory).Directory; - while (dir.GetDirectories("iisexpress").Length == 0) + while (!ContainsIIS(dir)) { if (dir.Parent == null) break; dir = dir.Parent; } + if (ContainsIIS(dir)) return dir.FullName; + dir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory; - while (dir.GetDirectories("iisexpress").Length == 0) + while (!ContainsIIS(dir)) { if (dir.Parent == null) throw new ApplicationException("Can't fine IISExpress folder."); dir = dir.Parent; @@ -55,5 +41,10 @@ namespace NzbDrone.Providers return dir.FullName; } } + + private static bool ContainsIIS(DirectoryInfo dir) + { + return dir.GetDirectories("iisexpress").Length != 0; + } } } \ No newline at end of file diff --git a/NzbDrone/Providers/ServiceProvider.cs b/NzbDrone/Providers/ServiceProvider.cs index 99c00140d..8667b28ad 100644 --- a/NzbDrone/Providers/ServiceProvider.cs +++ b/NzbDrone/Providers/ServiceProvider.cs @@ -15,7 +15,7 @@ namespace NzbDrone.Providers private static readonly Logger Logger = LogManager.GetLogger("Host.ServiceManager"); - + public virtual bool ServiceExist(string name) { @@ -32,7 +32,7 @@ namespace NzbDrone.Providers var installer = new ServiceProcessInstaller { - Account = ServiceAccount.NetworkService + Account = ServiceAccount.LocalSystem }; var serviceInstaller = new ServiceInstaller(); @@ -44,9 +44,9 @@ namespace NzbDrone.Providers serviceInstaller.Context = context; serviceInstaller.DisplayName = NzbDroneServiceName; serviceInstaller.ServiceName = NzbDroneServiceName; + serviceInstaller.Description = "NzbDrone Application Server"; serviceInstaller.StartType = ServiceStartMode.Automatic; - serviceInstaller.Parent = installer; serviceInstaller.Install(new ListDictionary()); @@ -63,5 +63,11 @@ namespace NzbDrone.Providers serviceInstaller.ServiceName = NzbDroneServiceName; serviceInstaller.Uninstall(null); } + + + public virtual void Run(ServiceBase service) + { + ServiceBase.Run(service); + } } } \ No newline at end of file diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs index 7eba497b0..265ecce69 100644 --- a/NzbDrone/Router.cs +++ b/NzbDrone/Router.cs @@ -36,18 +36,9 @@ namespace NzbDrone { Logger.Info("Application mode: {0}", applicationMode); - _applicationServer.IsRunningAsService(); - - while (!Debugger.IsAttached) - { - Thread.Sleep(1000); - } - - - if (_enviromentProvider.IsRunningAsService) + if (!_enviromentProvider.IsUserInteractive) { - _applicationServer.StartService(); - + _serviceProvider.Run(_applicationServer); } else { @@ -74,7 +65,15 @@ namespace NzbDrone } case ApplicationMode.UninstallService: { - _serviceProvider.UnInstall(); + if (!_serviceProvider.ServiceExist(ServiceProvider.NzbDroneServiceName)) + { + _consoleProvider.PrintServiceDoestExist(); + } + else + { + _serviceProvider.UnInstall(); + } + break; } default: From 2dd2dd6d0df546186c41e717e3e41be0f40a8b84 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Fri, 14 Oct 2011 17:59:24 -0700 Subject: [PATCH 4/4] Cleaned up some code, fixed broken build. --- NzbDrone/AppMain.cs | 5 ----- NzbDrone/ApplicationServer.cs | 3 --- NzbDrone/CentralDispatch.cs | 9 +-------- NzbDrone/Providers/ConsoleProvider.cs | 2 -- NzbDrone/Providers/IISProvider.cs | 2 +- NzbDrone/Providers/MonitoringProvider.cs | 2 +- NzbDrone/Router.cs | 3 --- 7 files changed, 3 insertions(+), 23 deletions(-) diff --git a/NzbDrone/AppMain.cs b/NzbDrone/AppMain.cs index 3960d8929..801ffae68 100644 --- a/NzbDrone/AppMain.cs +++ b/NzbDrone/AppMain.cs @@ -1,12 +1,7 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using System.Reflection; -using System.Threading; using NLog; using Ninject; -using NzbDrone.Model; namespace NzbDrone { diff --git a/NzbDrone/ApplicationServer.cs b/NzbDrone/ApplicationServer.cs index 8cb093b15..3da83013c 100644 --- a/NzbDrone/ApplicationServer.cs +++ b/NzbDrone/ApplicationServer.cs @@ -1,9 +1,6 @@ using System; -using System.Diagnostics; using System.Net; -using System.Reflection; using System.ServiceProcess; -using System.Threading; using NLog; using Ninject; using NzbDrone.Providers; diff --git a/NzbDrone/CentralDispatch.cs b/NzbDrone/CentralDispatch.cs index 6c4944f4e..bff41dd9b 100644 --- a/NzbDrone/CentralDispatch.cs +++ b/NzbDrone/CentralDispatch.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using NLog; +using NLog; using Ninject; -using NzbDrone.Model; using NzbDrone.Providers; namespace NzbDrone @@ -51,7 +45,6 @@ namespace NzbDrone _kernel.Get().ConfigureNlog(); _kernel.Get().CreateDefaultConfigFile(); Logger.Info("Start-up Path:'{0}'", _kernel.Get().ApplicationPath); - Thread.CurrentThread.Name = "Host"; } } } diff --git a/NzbDrone/Providers/ConsoleProvider.cs b/NzbDrone/Providers/ConsoleProvider.cs index e2281e905..cd45ce4f4 100644 --- a/NzbDrone/Providers/ConsoleProvider.cs +++ b/NzbDrone/Providers/ConsoleProvider.cs @@ -1,7 +1,5 @@ using System; using System.Diagnostics; -using System.Reflection; -using NLog; namespace NzbDrone.Providers { diff --git a/NzbDrone/Providers/IISProvider.cs b/NzbDrone/Providers/IISProvider.cs index 0e78fd8b3..ce2478f7d 100644 --- a/NzbDrone/Providers/IISProvider.cs +++ b/NzbDrone/Providers/IISProvider.cs @@ -120,7 +120,7 @@ namespace NzbDrone.Providers if (e.Data.Contains(" NzbDrone.")) { - System.Console.WriteLine(e.Data); + Console.WriteLine(e.Data); return; } diff --git a/NzbDrone/Providers/MonitoringProvider.cs b/NzbDrone/Providers/MonitoringProvider.cs index fecd3de10..55c80d0af 100644 --- a/NzbDrone/Providers/MonitoringProvider.cs +++ b/NzbDrone/Providers/MonitoringProvider.cs @@ -103,7 +103,7 @@ namespace NzbDrone.Providers private static void AppDomainException(object excepion) { - System.Console.WriteLine("EPIC FAIL: {0}", excepion); + Console.WriteLine("EPIC FAIL: {0}", excepion); Logger.Fatal("EPIC FAIL: {0}", excepion); #if RELEASE diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs index 265ecce69..7e72b3906 100644 --- a/NzbDrone/Router.cs +++ b/NzbDrone/Router.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Text; -using System.Threading; using NLog; using NzbDrone.Model; using NzbDrone.Providers;