Permalink
Browse files

Better handling of disposal concerns when running inside IIS

  • Loading branch information...
ayende committed Jan 20, 2012
1 parent e02a812 commit a2e4f22abf68e90921887ef3c8c9b7f124188302
Showing with 12 additions and 1 deletion.
  1. +0 −1 Raven.Web/BootStrapper.cs
  2. +12 −0 Raven.Web/ForwardToRavenRespondersFactory.cs
@@ -15,7 +15,6 @@ public void Init(HttpApplication context)
public void Dispose()
{
- ForwardToRavenRespondersFactory.Shutdown();
}
}
@@ -5,6 +5,7 @@
//-----------------------------------------------------------------------
using System;
using System.Web;
+using System.Web.Hosting;
using Raven.Database;
using Raven.Database.Config;
using Raven.Database.Server;
@@ -17,6 +18,15 @@ public class ForwardToRavenRespondersFactory : IHttpHandlerFactory
internal static HttpServer server;
private static readonly object locker = new object();
+ public class ReleaseRavenDBWhenAppDomainIsTornDown : IRegisteredObject
+ {
+ public void Stop(bool immediate)
+ {
+ Shutdown();
+ HostingEnvironment.UnregisterObject(this);
+ }
+ }
+
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
{
if (database == null)
@@ -61,6 +71,8 @@ public static void Init()
}
throw;
}
+
+ HostingEnvironment.RegisterObject(new ReleaseRavenDBWhenAppDomainIsTornDown());
}
}

0 comments on commit a2e4f22

Please sign in to comment.