Configure Apache to recover from mod_python errors

2019-08-16 01:48发布

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.

  1. Is there any way to configure the Apache logs to include a subprocess id?
  2. Is there any way to force a subprocess to respawn if it has hit an error?
  3. Are there any known issues relating to this that I should know about?

2条回答
趁早两清
2楼-- · 2019-08-16 02:14

A more detailed version of this question with accepted answer is available at this reposting:

Testing for mysterious load errors in python/django

查看更多
神经病院院长
3楼-- · 2019-08-16 02:19

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.

查看更多
登录 后发表回答