难以让flup fcgi脚本工作

时间:2010-01-06 15:22:54

标签: python django fastcgi flup

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

我用一个简单的hello world脚本替换了fcgi脚本:

#!/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被创建了。如果我是x.pyc,然后点击该网站,则不会创建x.pyc。

我还注意到错误已从

更改
terminated by calling exit with status '118'

terminated by calling exit with status '116'

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

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

嘿,谢谢!我只是粘贴评论。

  • 您使用什么服务器来运行mymembers.fcgi? - 东武
  • Debian Etch,Apache 1.3网址是mymembers.co.za - Gary van der Merwe
  • 我怀疑mod_fastcgi配置错误。请发布或粘贴您的apache配置的相关部分。 - 东武
  • 由于这是托管在共享主机上,我没想到要查看配置。看着配置帮我找到了问题,所以你真的帮助了我。我希望我能够将赏金奖励给你。 meta.stackoverflow.com/questions/35081 / ... - Gary van der Merwe