问题
I am hosting a Django app on Apache using mod_python. Occasionally, I get some cryptic mod_python errors, usually of the ImportError
variety, although not usually referring to the same module. The thing is, these seem to come up for a single forked subprocess, while the others operate fine, even when I force behavior that requires using the module that the problem process has errored on. Once the process encounters the error, it will always just serve the same traceback every time Apache chooses it to handle a request. (This is also a hassle, since my users don't necessarily report the error on the first occurrence, and once the process encounters the error.)
I know more about configuring Django than configuring Apache, but that won't get me anywhere since the request never reaches Django for processing. Ideally, I should solve the root problem, and that might involve my code, project, or machine configuration, but until then, I need help diagnosing and mitigating the problem.
- Is there any way to configure the Apache logs to include a subprocess id?
- Is there any way to force a subprocess to respawn if it has hit an error?
- Are there any known issues relating to this that I should know about?
回答1:
As a workaround, and assuming you are free to install new Apache modules on the server, you might try one of
- mod_scgi
- mod_fastcgi
- mod_wsgi
instead. I use SCGI to connect an nginx frontend webserver to my Django apps, which highlights a major benefit (decoupling from the webserver). All of these packages are available in Debian, probably on RHELx as well.
来源:https://stackoverflow.com/questions/926579/configure-apache-to-recover-from-mod-python-errors