让 flup fcgi 脚本正常工作很困难

发布于 2024-08-17 03:49:26 字数 2881 浏览 3 评论 0原文

我正在使用 django 为客户构建一个网站。它托管在共享主机上,无法使用 mod_wsgi。去年,我使用 fcgi 让它工作,但是当我回来时,它坏了。

我已将 fcgi 脚本替换为简单的 hello world 脚本:

#!/usr/bin/python
def myapp(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello World!\n']

try:
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp).run()
except:
    import sys, traceback
    traceback.print_exc(file=open("errlog.txt","a"))

在本地服务器上测试并工作,但在托管服务器上,我收到此错误:

<title>FCGI Error</title>
A timeout occured while waiting for the script output (in: /usr/www/users/mymemb/).

如果我查看错误日志,我会看到以下内容:

[Wed Jan  6 16:59:37 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" (user mymemb, gid 100) restarted (pid 1057)

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" (pid 1057) terminated by calling exit with status '118'

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

etc ...

如果我 ssh 到服务器,我可以正常运行该脚本,并输出以下输出:

mymemb@www81:~/public_html$ ./mymembers.fcgi 
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/plain
Content-Length: 13

Hello World!

如何解决此问题?

添加信息:

看起来脚本根本没有运行。如果我在脚本顶部添加 import x 并从 ssh 运行它,我会看到 x.pyc 被创建。如果我 rm x.pyc,然后点击该站点,则不会创建 x.pyc。

我还注意到错误从 变为

terminated by calling exit with status '118'

terminated by calling exit with status '116'

希望我能找到这些退出状态的参考。

I'm building a site for a client using django. It's been hosted on shared hosting and mod_wsgi can't be used. In the old year, I got it working using fcgi, but when I got back, it was broken.

I have replaced the fcgi script with a simple hello world script:

#!/usr/bin/python
def myapp(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello World!\n']

try:
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp).run()
except:
    import sys, traceback
    traceback.print_exc(file=open("errlog.txt","a"))

Tested and working on my local server, but on the hosted server, I get this error:

<title>FCGI Error</title>
A timeout occured while waiting for the script output (in: /usr/www/users/mymemb/).

If I look at the error log, I see this:

[Wed Jan  6 16:59:37 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" (user mymemb, gid 100) restarted (pid 1057)

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" (pid 1057) terminated by calling exit with status '118'

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

[Wed Jan  6 16:59:38 2010] [warn] FastCGI: (dynamic) server "/usr/www/users/mymemb/mymembers.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 10 seconds

etc ...

If I ssh to the server, I can run the script fine, with the following output:

mymemb@www81:~/public_html$ ./mymembers.fcgi 
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 200 OK
Content-Type: text/plain
Content-Length: 13

Hello World!

How do I fix this?

Added info:

It seems like the script is not running at all. If I add import x at the top of the script, and run it from ssh, I see that x.pyc gets created. If I rm x.pyc, and then hit the site, x.pyc does not get created.

I also noticed that the errors changed from

terminated by calling exit with status '118'

to

terminated by calling exit with status '116'

I wish I could find a reference for these exit statuses.

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

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

发布评论

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

评论(1

萌无敌 2024-08-24 03:49:26

退出状态 116 和 118 来自 suexec。通过阅读源代码,我发现这些错误是由组或其他人可写文件/目录引起的,suexec认为这是一个安全问题。从组中删除写入权限解决了该问题。

The exit status 116 and 118 were coming from suexec. By reading the source code, I found that these errors are caused by the file/dir being writable by group or others, which suexec considers as a security issue. Removing write access from group fixed the problem.

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