Browse files

Fixed #6687: added outlog/errlog options to runfcgi. Thanks, tamas.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7297 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent f0dec08 commit a752a3d41973dfae6c03d927f030e5975e836e6b @jacobian jacobian committed Mar 18, 2008
Showing with 14 additions and 2 deletions.
  1. +12 −2 django/core/servers/fastcgi.py
  2. +2 −0 django/utils/daemonize.py
View
14 django/core/servers/fastcgi.py
@@ -37,7 +37,9 @@
maxchildren=NUMBER hard limit number of processes / threads
daemonize=BOOL whether to detach from terminal.
pidfile=FILE write the spawned process-id to this file.
- workdir=DIRECTORY change to this directory when daemonizing
+ workdir=DIRECTORY change to this directory when daemonizing.
+ outlog=FILE write stdout to this file.
+ errlog=FILE write stderr to this file.
Examples:
Run a "standard" fastcgi process on a file-descriptor
@@ -69,6 +71,8 @@
'minspare': 2,
'maxchildren': 50,
'maxrequests': 0,
+ 'outlog': None,
+ 'errlog': None,
}
def fastcgi_help(message=None):
@@ -150,9 +154,15 @@ def runfastcgi(argset=[], **kwargs):
else:
return fastcgi_help("ERROR: Invalid option for daemonize parameter.")
+ daemon_kwargs = {}
+ if options['outlog']:
+ daemon_kwargs['out_log'] = options['outlog']
+ if options['errlog']:
+ daemon_kwargs['err_log'] = options['errlog']
+
if daemonize:
from django.utils.daemonize import become_daemon
- become_daemon(our_home_dir=options["workdir"])
+ become_daemon(our_home_dir=options["workdir"], **daemon_kwargs)
if options["pidfile"]:
fp = open(options["pidfile"], "w")
View
2 django/utils/daemonize.py
@@ -29,6 +29,8 @@ def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null'):
os.dup2(si.fileno(), sys.stdin.fileno())
os.dup2(so.fileno(), sys.stdout.fileno())
os.dup2(se.fileno(), sys.stderr.fileno())
+ # Set custom file descriptors so that they get proper buffering.
+ sys.stdout, sys.stderr = so, se
else:
def become_daemon(our_home_dir='.', out_log=None, err_log=None):
"""

0 comments on commit a752a3d

Please sign in to comment.