rvanlaar/djangorecipe — Issue #32: dajngo.fcgi calls runfastcgi() with default options
Author: rvanlaar
Created: 2011-12-27 21:40:39+00:00
State: open
Labels: fastcgi, Fix Released, Undecided

Right now djangorecipe specifies only "outlog" and "errlog" keyword arguments when calling runfastcgi() which can be suboptimal.
For example by default runfastcgi() uses method='prefork' which leads to the increased memory usage.

djangorecipe should provide some way to specify custom runfastcgi() options

For example use some variable defined in the project settings. I think it's a good place for fastcgi options. Djangorecipe already provides a facility to use one of available settings modules.

I slightly modified djangorecipe and made following changes to djangorecipe/fcgi.py (the same as attached diff):

diff --git a/src/djangorecipe/fcgi.py b/src/djangorecipe/fcgi.py
index 10eef4e..e814d2b 100644
--- a/src/djangorecipe/fcgi.py
+++ b/src/djangorecipe/fcgi.py
@@ -16,7 +16,9 @@ def main(settings_file, logfile=None):
# Setup settings
management.setup_environ(mod)

- options = {}
+ from django.conf import settings
+
+ options = getattr(settings, 'FASTCGI_OPTIONS', {})
if logfile:
options['outlog'] = logfile
options['errlog'] = logfile

In settings.py I've added:

FASTCGI_OPTIONS = {
'method': 'threaded',
}

It works for me.

Please consider using this diff, or provide some other way to specify custom fastcgi options.