English 中文(简体)
How can I show a maintenance page when my FastCGI app is restarting?
原标题:

I am serving my FastCGI application in Apache2 using the standalone FastCGI server and the FastCgiExternalServer directive.

When I restart my FastCGI app my users get a 500 error. What can I do to prevent this? I want to show them a nice maintenance page or something.

It is a Catalyst application written in perl and I have followed the example here but I have found that a 500 is served and not a 502 bad gateway so I can t select what error to show. I don t want to serve a maintenance page for a legitimate internal server error.

最佳回答

Your only real choices are

  1. Use ErrorDocument 500 and design a page that s suitable for either situation, or
  2. Hack/fix mod_fastcgi to return a 502 instead of a 500 like the folk wisdom thinks it should.

mod_fastcgi development is very slow, but not completely dead, so you could always try sending that patch upstream; if it was accepted it would be appreciated. :)

问题回答

Thanks Hobbs,

I took your advise and created a patch file. This is working for me. I know this is an old question, but it helped me, hopefully this will help others.

--- mod_fastcgi-SNAP-0910052141/mod_fastcgi.c   2008-11-09 07:31:03.000000000 -0700
+++ mod_fastcgi-SNAP-BadGateway/mod_fastcgi.c   2012-06-01 10:42:48.497212761 -0600
@@ -1670,7 +1670,7 @@
                 if (open_connection_to_fs(fr) != FCGI_OK) 
                 {
                     ap_kill_timeout(r);
-                    return HTTP_INTERNAL_SERVER_ERROR;
+                    return HTTP_BAD_GATEWAY;
                 }

                 is_connected = 1;
@@ -2079,7 +2079,7 @@
                 if (open_connection_to_fs(fr) != FCGI_OK) 
                 {
                     ap_kill_timeout(r);
-                    return HTTP_INTERNAL_SERVER_ERROR;
+                    return HTTP_BAD_GATEWAY;
                 }

                 set_nonblocking(fr, TRUE);
@@ -2387,6 +2387,11 @@
     {
         sink_client_data(fr);
     }
+    
+    //if we failed to connect to FastCGI Server, return error now. Do not try to parse headers
+    if (rv == HTTP_BAD_GATEWAY) {
+       return rv;
+    }

     while (rv == 0 && (BufferLength(fr->serverInputBuffer) || BufferLength(fr->clientOutputBuffer)))
     {




相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签