jschementi / iron

[Jimmy Schementi's development fork] Implementations of Python and Ruby programming languages for .NET Framework that are built on top of the Dynamic Language Runtime.
http://ironruby.net
17 stars 2 forks source link

Rack and IIS6 #25

Closed jschementi closed 15 years ago

jschementi commented 15 years ago

Martin Smith [martin.smith.jr@gmail.com]

I wanted to let you know I was having all sorts of troubles getting Rails to start reliably running on IIS6 (though I don't think IIS6 has anything to do with it) and I had to increase the script timeout for the very first load of the application.

I changed HttpHandler to the one i've included below. I think the locking is right, but has the side effect of possibly a few of the early scripts getting a longer timeout than expected. That's probably ok, but I'm not sure it's an "enterprise ready" solution.

What do you guys think? Source included below.

internal sealed class HttpHandler : IHttpHandler {

    private readonly Stopwatch _watch = new Stopwatch();
    private static bool _isFirstRequest = true; // added this

    public bool IsReusable {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context) {
        lock (this) {
            if (_isFirstRequest) // added this if block
            {
                context.Server.ScriptTimeout = 600;
                _isFirstRequest = false;
            }

            Utils.Log("");
            Utils.Log("=== Request started at " + DateTime.Now.ToString());
            _watch.Reset();
            _watch.Start();

            Handler.IIS.Current.Handle(
              new Request(new HttpRequestWrapper(context.Request)),
              new Response(new HttpResponseWrapper(context.Response)));

            _watch.Stop();
            Utils.Log(">>> Request finished (" + _watch.ElapsedMilliseconds.ToString() + "ms)");
        }
    }
}
jschementi commented 15 years ago

This doesn't seem like an issue with IIS6 --- more-so that the app requires 600 seconds to start!? Following up on the mailing list.