我正在为使用 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 已创建。如果我 rm x.pyc,然后点击该站点,则不会创建 x.pyc。
我还注意到错误从
terminated by calling exit with status '118'
到
terminated by calling exit with status '116'
我希望我能找到这些退出状态的参考。