当我的 FastCGI 应用程序重新启动时,如何显示维护页面?

发布于 2024-08-10 20:16:52 字数 427 浏览 12 评论 0原文

我使用独立的 FastCGI 服务器和 FastCgiExternalServer 指令在 Apache2 中为我的 FastCGI 应用程序提供服务。

当我重新启动 FastCGI 应用程序时,我的用户收到 500 错误。我可以做什么来防止这种情况发生?我想向他们展示一个不错的“维护”页面或其他内容。

这是一个用 Perl 编写的 Catalyst 应用程序,我遵循了示例 此处,但我发现提供的是 500,而不是 502 错误网关,因此我无法选择要显示的错误。我不想为合法的内部服务器错误提供维护页面。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心舞飞扬 2024-08-17 20:16:52

您唯一真正的选择是

  1. 使用 ErrorDocument 500 并设计一个适合这两种情况的页面,或者
  2. Hack/fix mod_fastcgi 返回 502,而不是像民间智慧认为的那样返回 500。

mod_fastcgi 开发非常缓慢,但还没有完全消亡,因此您可以随时尝试向上游发送该补丁;如果它被接受,我们将不胜感激。 :)

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. :)

や莫失莫忘 2024-08-17 20:16:52

谢谢霍布斯,

我采纳了你的建议并创建了一个补丁文件。这对我有用。我知道这是一个老问题,但它对我有帮助,希望这对其他人有帮助。

--- 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)))
     {

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)))
     {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文