Django Apache FastCGI 重启
根据 Django 文档,Django 可以使用 FastCGI 进行配置。
这是我们的设置(请注意,我不控制工作场所的 Apache 设置,并且我需要使用 FastCGI,因为我们已经拥有它,而不是安装 WSGI):
我们的 apache conf 中与 fcgi 相关的部分是:
LoadModule fastcgi_module modules/mod_fastcgi.so
# IPC directory location
#
FastCgiIpcDir "/path/to/FastCGI_IPC"
# General CGI config
#
FCGIConfig -idle-timeout 30 -listen-queue-depth 4 -maxProcesses 40 -minProcesses 10 -maxClassProcesses 2 -killInterval 60 -updateInterval 20 -singleThreshhold 0 -multiThreshhold 10 -processSlack 5 -failed-restart-delay 10
# To use FastCGI scripts:
#
AddHandler fastcgi-script .fcg .fcgi .fpl
FastCgiServer "/path/to/my/django.fcgi" -listen-queue-depth 24 -processes 8 -restart-delay 1 -min-server-life 2 -failed-restart-delay 10
最后一行应该是最相关的。我的 django.fcgi 是:
#!/path/to/python-2.5/bin/python
import sys, os
open('pid', "w").write("%d" % (os.getpid()))
# Add a custom Python path.
sys.path.insert(0, "/path/to/django/")
sys.path.insert(0, "/path/to/python2.5/site-packages/")
# Switch to the directory of your project. (Optional.)
os.chdir("/path/to/django/site")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "site.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
根据
http: //docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#restarting-the-spawned-server
重新启动 fcgi 应该很简单,
touch django.fcgi
但对我们来说,它不会导致重新启动(这就是为什么我将 pid 写入文件)。
为什么触摸 django.fcgi 不起作用?
According to Django docs Django can be configured with FastCGI.
Here's our setup (note that I don't control Apache setup at my workplace and I'm required to use FastCGI since we already have it, rather than install WSGI):
The fcgi-relevant part of our apache conf is:
LoadModule fastcgi_module modules/mod_fastcgi.so
# IPC directory location
#
FastCgiIpcDir "/path/to/FastCGI_IPC"
# General CGI config
#
FCGIConfig -idle-timeout 30 -listen-queue-depth 4 -maxProcesses 40 -minProcesses 10 -maxClassProcesses 2 -killInterval 60 -updateInterval 20 -singleThreshhold 0 -multiThreshhold 10 -processSlack 5 -failed-restart-delay 10
# To use FastCGI scripts:
#
AddHandler fastcgi-script .fcg .fcgi .fpl
FastCgiServer "/path/to/my/django.fcgi" -listen-queue-depth 24 -processes 8 -restart-delay 1 -min-server-life 2 -failed-restart-delay 10
The last line should be most relevant. My django.fcgi is:
#!/path/to/python-2.5/bin/python
import sys, os
open('pid', "w").write("%d" % (os.getpid()))
# Add a custom Python path.
sys.path.insert(0, "/path/to/django/")
sys.path.insert(0, "/path/to/python2.5/site-packages/")
# Switch to the directory of your project. (Optional.)
os.chdir("/path/to/django/site")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "site.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
According to
http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#restarting-the-spawned-server
restarting the fcgi should be as simple as
touch django.fcgi
but for us it doesn't result in a restart (which is why I'm writing the pid's to files).
Why doesn't the touch django.fcgi work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道,但我可以提出一个不涉及安装任何东西的替代解决方案:
只需在任意本地主机端口(例如 50000)上运行 django,然后执行以下操作:
它所需要的只是标准的 mod_rewrite 和 mod_proxy。
I don't know, but I can propose an alternate solution that doesn't involve installing anything:
Just run django on some arbitrary localhost port (say 50000), and then do this:
All it requires are the standard mod_rewrite and mod_proxy.
好吧,那么,对你的问题进行实际的回答。 :)
看起来你缺少一个选项。
-- http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi。 html#FastCgiConfig
Okay, an actual answer to your question, then. :)
Looks like you're missing an option.
-- http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiConfig