Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top