Lighttpd、FastCGI、Django - 如何自动重启?

发布于 2024-08-05 00:40:09 字数 188 浏览 3 评论 0原文

我在开发机器上使用 Lighttpd + FastCGI + Django。我通过manage.py 的命令行选项启动FastCGI 服务器。

问题是我确实经常对源进行更改,并且我需要让 FastCGI 自动获取这些更改,就像“./manage.py runserver”所做的那样。

是否有一个命令行选项,或者任何其他解决方案?

I am using Lighttpd + FastCGI + Django on a dev machine. I start FastCGI server via manage.py's command line option.

Problem is that I do make changes to sources quite often and I need to get FastCGI to pick up those changes automatically, just as "./manage.py runserver" does.

Is there a command-line option for that, perhaps, or any other solutions?

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

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

发布评论

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

评论(2

影子是时光的心 2024-08-12 00:40:09

您是否看过manage.py 的runserver 部分中用于监控的代码?我认为您没有理由不能将该代码复制粘贴到自定义的 manage.py 脚本中,并将其设置为在检测到更改时运行轻松重新启动命令。

或者,您可以运行一个单独的 python 程序,使用 pyinotify 之类的包进行重新启动:

http://trac.dbzteam .org/pyinotify

Have you looked at the code in the runserver part of manage.py that does the monitoring? I see no reason you could not just copy-paste that code into a custom manage.py script and set it to run the lighty restart command when changes were detected.

Alternatively, you could run a separate python program that did the restart using a package like pyinotify:

http://trac.dbzteam.org/pyinotify

浮光之海 2024-08-12 00:40:09

我想知道是否有人曾经让它工作过?我尝试使用 django 的 autoreload.py 实现重新加载机制,不幸的是,当 fork 发生时,我收到错误,例如:

django/core/servers/fastcgi.py", line 180, in runfastcgi
WSGIServer(WSGIHandler(), **wsgi_opts).run()
文件“build/bdist.freebsd-6.4-RELEASE-p9-amd64/egg/flup/server/fcgi_fork.py”,第 140 行,运行中
文件“build/bdist.freebsd-6.4-RELEASE-p9-amd64/egg/flup/server/preforkserver.py”,第 119 行,运行中
文件“build/bdist.freebsd-6.4-RELEASE-p9-amd64/egg/flup/server/preforkserver.py”,第 450 行,位于 _installSignalHandlers 中
ValueError: signal only works in main thread

我理想的设置是能够重新加载/终止我的 fcgi 进程,并在每次检测到代码更改后启动一个新进程,类似于 django 在其内部服务器上执行此操作的方式。我还尝试从 autoreload.py 中删除线程,以解决此错误,但它似乎无法正确运行服务器(仍在调查)。

也许有人在 django 的 settings.py 文件中尝试过 CherryPies autoreload.py ?

I'm wondering if anyone has ever gotten this to work? I have tried implementing a reload mechanism using django's autoreload.py, unfortunately, I get errors when the fork occurs like:

django/core/servers/fastcgi.py", line 180, in runfastcgi
WSGIServer(WSGIHandler(), **wsgi_opts).run()
File "build/bdist.freebsd-6.4-RELEASE-p9-amd64/egg/flup/server/fcgi_fork.py", line 140, in run
File "build/bdist.freebsd-6.4-RELEASE-p9-amd64/egg/flup/server/preforkserver.py", line 119, in run
File "build/bdist.freebsd-6.4-RELEASE-p9-amd64/egg/flup/server/preforkserver.py", line 450, in _installSignalHandlers
ValueError: signal only works in main thread

My ideal setup would be to be able to reload/kill my fcgi process and start a new one after each time a code change is detected, similar to how django does this with their internal server. I also tried removing the threading from autoreload.py that would get past this error, but it does not seem to run the server properly (still investigating that).

Perhaps someone has tried CherryPies autoreload.py in the settings.py file for django?

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