diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj
index a7b36c17c..8f570c0f1 100644
--- a/NzbDrone.Common/NzbDrone.Common.csproj
+++ b/NzbDrone.Common/NzbDrone.Common.csproj
@@ -59,18 +59,6 @@
..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll
-
- ..\packages\Microsoft.Owin.Host.HttpListener.0.21.0-pre\lib\net40\Microsoft.Owin.Host.HttpListener.dll
-
-
- ..\packages\Microsoft.Owin.Hosting.0.21.0-pre\lib\net40\Microsoft.Owin.Hosting.dll
-
-
- ..\packages\Nancy.0.16.1\lib\net40\Nancy.dll
-
-
- ..\packages\Nancy.Owin.0.16.1\lib\net40\Nancy.Owin.dll
-
False
..\packages\Newtonsoft.Json.5.0.3\lib\net35\Newtonsoft.Json.dll
@@ -79,15 +67,10 @@
False
..\packages\NLog.2.0.1.2\lib\net40\NLog.dll
-
- ..\packages\Owin.1.0\lib\net40\Owin.dll
-
-
-
@@ -131,7 +114,6 @@
-
@@ -153,10 +135,6 @@
-
- Form
-
-
diff --git a/NzbDrone.Common/ProcessProvider.cs b/NzbDrone.Common/ProcessProvider.cs
index cdf645d24..7ae01bcee 100644
--- a/NzbDrone.Common/ProcessProvider.cs
+++ b/NzbDrone.Common/ProcessProvider.cs
@@ -110,5 +110,10 @@ namespace NzbDrone.Common
Name = process.ProcessName
};
}
+
+ public void KillAll(string nzbdrone)
+ {
+ throw new System.NotImplementedException();
+ }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Common/packages.config b/NzbDrone.Common/packages.config
index fbdb19d5b..501d8b269 100644
--- a/NzbDrone.Common/packages.config
+++ b/NzbDrone.Common/packages.config
@@ -1,11 +1,6 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/NzbDrone.Core/Lifecycle/AppRestartJob.cs b/NzbDrone.Core/Lifecycle/AppRestartJob.cs
deleted file mode 100644
index 33643e5ae..000000000
--- a/NzbDrone.Core/Lifecycle/AppRestartJob.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Linq;
-using NLog;
-using NzbDrone.Common;
-using NzbDrone.Core.Jobs;
-using NzbDrone.Core.Model.Notification;
-
-namespace NzbDrone.Core.Lifecycle
-{
- public class AppRestartJob : IJob
- {
- private readonly IHostController _hostController;
-
- private static readonly Logger logger = LogManager.GetCurrentClassLogger();
-
- public AppRestartJob(IHostController hostController)
- {
- _hostController = hostController;
- }
-
- public string Name
- {
- get { return "Restart NzbDrone"; }
- }
-
- public TimeSpan DefaultInterval
- {
- get { return TimeSpan.FromTicks(0); }
- }
-
- public virtual void Start(ProgressNotification notification, dynamic options)
- {
- notification.CurrentMessage = "Restarting NzbDrone";
- logger.Info("Restarting NzbDrone");
-
- _hostController.StopServer();
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index fe9ac65ed..b5b6ea7f8 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -300,7 +300,6 @@
-
diff --git a/NzbDrone.Integration.Test/IntegrationTest.cs b/NzbDrone.Integration.Test/IntegrationTest.cs
index 2c64fae44..3ac0ca7e3 100644
--- a/NzbDrone.Integration.Test/IntegrationTest.cs
+++ b/NzbDrone.Integration.Test/IntegrationTest.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Linq;
using Moq;
using NLog;
using NLog.Config;
@@ -11,6 +12,8 @@ using NzbDrone.Api.RootFolders;
using NzbDrone.Common;
using NzbDrone.Core.Datastore;
using NzbDrone.Integration.Test.Client;
+using NzbDrone.Owin;
+using NzbDrone.Owin.MiddleWare;
using RestSharp;
using TinyIoC;
@@ -85,7 +88,7 @@ namespace NzbDrone.Integration.Test
var _hostConfig = new Mock();
_hostConfig.SetupGet(c => c.Port).Returns(1313);
- _hostController = new OwinHostController(_hostConfig.Object, _bootstrapper, Logger);
+ _hostController = new OwinHostController(_hostConfig.Object, new[] { new NancyMiddleWare(_bootstrapper) }, Logger);
RestClient = new RestClient(_hostController.AppUrl + "/api/");
diff --git a/NzbDrone.Update/Providers/UpdateProvider.cs b/NzbDrone.Update/Providers/UpdateProvider.cs
index e825f8db7..16520130b 100644
--- a/NzbDrone.Update/Providers/UpdateProvider.cs
+++ b/NzbDrone.Update/Providers/UpdateProvider.cs
@@ -12,17 +12,15 @@ namespace NzbDrone.Update.Providers
private readonly ServiceProvider _serviceProvider;
private readonly ProcessProvider _processProvider;
private readonly EnvironmentProvider _environmentProvider;
- private readonly IHostController _hostController;
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public UpdateProvider(DiskProvider diskProvider, ServiceProvider serviceProvider,
- ProcessProvider processProvider, EnvironmentProvider environmentProvider, IHostController hostController)
+ ProcessProvider processProvider, EnvironmentProvider environmentProvider)
{
_diskProvider = diskProvider;
_serviceProvider = serviceProvider;
_processProvider = processProvider;
_environmentProvider = environmentProvider;
- _hostController = hostController;
}
public UpdateProvider()
@@ -79,7 +77,7 @@ namespace NzbDrone.Update.Providers
}
logger.Info("Killing all orphan IISExpress processes");
- _hostController.StopServer();
+ _processProvider.KillAll("NzbDrone");
logger.Info("Creating backup of existing installation");
_diskProvider.CopyDirectory(targetFolder, _environmentProvider.GetUpdateBackUpFolder());
diff --git a/NzbDrone/ApplicationServer.cs b/NzbDrone/ApplicationServer.cs
index 00bb9262c..5c33b6f88 100644
--- a/NzbDrone/ApplicationServer.cs
+++ b/NzbDrone/ApplicationServer.cs
@@ -2,6 +2,7 @@
using System.ServiceProcess;
using NLog;
using NzbDrone.Common;
+using NzbDrone.Owin;
namespace NzbDrone
{
diff --git a/NzbDrone/NzbDrone.csproj b/NzbDrone/NzbDrone.csproj
index cb92e94c5..ab9ddbb9e 100644
--- a/NzbDrone/NzbDrone.csproj
+++ b/NzbDrone/NzbDrone.csproj
@@ -91,6 +91,7 @@
False
..\packages\FluentMigrator.1.0.6.0\tools\FluentMigrator.Runner.dll
+
..\packages\Microsoft.Owin.Host.HttpListener.0.21.0-pre\lib\net40\Microsoft.Owin.Host.HttpListener.dll
@@ -115,7 +116,9 @@
+
+
@@ -127,9 +130,18 @@
+
+
+
+
+
+
+ Form
+
+
diff --git a/NzbDrone/Owin/IHostController.cs b/NzbDrone/Owin/IHostController.cs
new file mode 100644
index 000000000..7d5150437
--- /dev/null
+++ b/NzbDrone/Owin/IHostController.cs
@@ -0,0 +1,10 @@
+namespace NzbDrone.Owin
+{
+ public interface IHostController
+ {
+ string AppUrl { get; }
+ void StartServer();
+ void RestartServer();
+ void StopServer();
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone/Owin/MiddleWare/IOwinMiddleWare.cs b/NzbDrone/Owin/MiddleWare/IOwinMiddleWare.cs
new file mode 100644
index 000000000..80a85102f
--- /dev/null
+++ b/NzbDrone/Owin/MiddleWare/IOwinMiddleWare.cs
@@ -0,0 +1,9 @@
+using Owin;
+
+namespace NzbDrone.Owin.MiddleWare
+{
+ public interface IOwinMiddleWare
+ {
+ void Attach(IAppBuilder appBuilder);
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone/Owin/MiddleWare/NancyMiddleWare.cs b/NzbDrone/Owin/MiddleWare/NancyMiddleWare.cs
new file mode 100644
index 000000000..a30a5ea8b
--- /dev/null
+++ b/NzbDrone/Owin/MiddleWare/NancyMiddleWare.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Nancy.Bootstrapper;
+using Nancy.Owin;
+using Owin;
+
+namespace NzbDrone.Owin.MiddleWare
+{
+ public class NancyMiddleWare : IOwinMiddleWare
+ {
+ private readonly INancyBootstrapper _nancyBootstrapper;
+
+ public NancyMiddleWare(INancyBootstrapper nancyBootstrapper)
+ {
+ _nancyBootstrapper = nancyBootstrapper;
+ }
+
+ public void Attach(IAppBuilder appBuilder)
+ {
+ var nancyOwinHost = new NancyOwinHost(null, _nancyBootstrapper);
+ appBuilder.Use((Func, Task>, Func, Task>>)(next => (Func, Task>)nancyOwinHost.Invoke), new object[0]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone/Owin/MiddleWare/SignalRMiddleWare.cs b/NzbDrone/Owin/MiddleWare/SignalRMiddleWare.cs
new file mode 100644
index 000000000..fddb7c0b4
--- /dev/null
+++ b/NzbDrone/Owin/MiddleWare/SignalRMiddleWare.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Nancy.Bootstrapper;
+using Nancy.Owin;
+using Owin;
+
+namespace NzbDrone.Owin.MiddleWare
+{
+ public class SignalRMiddleWare : IOwinMiddleWare
+ {
+ private readonly INancyBootstrapper _nancyBootstrapper;
+
+ public SignalRMiddleWare(INancyBootstrapper nancyBootstrapper)
+ {
+ _nancyBootstrapper = nancyBootstrapper;
+ }
+
+ public void Attach(IAppBuilder appBuilder)
+ {
+ return;
+ var nancyOwinHost = new NancyOwinHost(null, _nancyBootstrapper);
+ appBuilder.Use((Func, Task>, Func, Task>>)(next => (Func, Task>)nancyOwinHost.Invoke), new object[0]);
+ }
+ }
+}
\ No newline at end of file
diff --git a/NzbDrone.Common/HostController.cs b/NzbDrone/Owin/OwinHostController.cs
similarity index 74%
rename from NzbDrone.Common/HostController.cs
rename to NzbDrone/Owin/OwinHostController.cs
index c89898ef2..cafe31a80 100644
--- a/NzbDrone.Common/HostController.cs
+++ b/NzbDrone/Owin/OwinHostController.cs
@@ -5,36 +5,37 @@ using Microsoft.Owin.Hosting;
using NLog;
using Nancy.Bootstrapper;
using Nancy.Owin;
+using NzbDrone.Common;
+using NzbDrone.Owin.MiddleWare;
using Owin;
-namespace NzbDrone.Common
+namespace NzbDrone.Owin
{
- public interface IHostController
- {
- string AppUrl { get; }
- void StartServer();
- void RestartServer();
- void StopServer();
- }
-
-
public class OwinHostController : IHostController
{
private readonly ConfigFileProvider _configFileProvider;
- private readonly INancyBootstrapper _bootstrapper;
+ private readonly IEnumerable _owinMiddleWares;
private readonly Logger _logger;
private IDisposable _host;
- public OwinHostController(ConfigFileProvider configFileProvider, INancyBootstrapper bootstrapper, Logger logger)
+ public OwinHostController(ConfigFileProvider configFileProvider, IEnumerable owinMiddleWares, Logger logger)
{
_configFileProvider = configFileProvider;
- _bootstrapper = bootstrapper;
+ _owinMiddleWares = owinMiddleWares;
_logger = logger;
}
public void StartServer()
{
- _host = WebApplication.Start(AppUrl, builder => RunNancy(builder, _bootstrapper));
+ _host = WebApplication.Start(AppUrl, BuildApp);
+ }
+
+ private void BuildApp(IAppBuilder appBuilder)
+ {
+ foreach (var middleWare in _owinMiddleWares)
+ {
+ middleWare.Attach(appBuilder);
+ }
}
private static IAppBuilder RunNancy(IAppBuilder builder, INancyBootstrapper bootstrapper)
@@ -67,5 +68,4 @@ namespace NzbDrone.Common
}
}
-
}
\ No newline at end of file
diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs
index ad0cbe8f5..e513cc53b 100644
--- a/NzbDrone/Router.cs
+++ b/NzbDrone/Router.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common;
-using NzbDrone.Common.SysTray;
+using NzbDrone.SysTray;
namespace NzbDrone
{
diff --git a/NzbDrone.Common/SysTray/SysTrayApp.cs b/NzbDrone/SysTray/SysTrayApp.cs
similarity index 96%
rename from NzbDrone.Common/SysTray/SysTrayApp.cs
rename to NzbDrone/SysTray/SysTrayApp.cs
index 25fc80489..34b526cac 100644
--- a/NzbDrone.Common/SysTray/SysTrayApp.cs
+++ b/NzbDrone/SysTray/SysTrayApp.cs
@@ -1,10 +1,11 @@
using System;
using System.Drawing;
-using System.Linq;
using System.Reflection;
using System.Windows.Forms;
+using NzbDrone.Common;
+using NzbDrone.Owin;
-namespace NzbDrone.Common.SysTray
+namespace NzbDrone.SysTray
{
public class SysTrayApp : Form
{
diff --git a/NzbDrone.Common/SysTray/SysTrayProvider.cs b/NzbDrone/SysTray/SysTrayProvider.cs
similarity index 82%
rename from NzbDrone.Common/SysTray/SysTrayProvider.cs
rename to NzbDrone/SysTray/SysTrayProvider.cs
index e3b0057e1..2b3561909 100644
--- a/NzbDrone.Common/SysTray/SysTrayProvider.cs
+++ b/NzbDrone/SysTray/SysTrayProvider.cs
@@ -1,7 +1,6 @@
-using System.Linq;
-using System.Windows.Forms;
+using System.Windows.Forms;
-namespace NzbDrone.Common.SysTray
+namespace NzbDrone.SysTray
{
public class SysTrayProvider
{