Skip to content

Commit

Permalink
Fixed #6687: added outlog/errlog options to runfcgi. Thanks, tamas.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7297 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jacobian committed Mar 18, 2008
1 parent f0dec08 commit a752a3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions django/core/servers/fastcgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,6 +71,8 @@
'minspare': 2,
'maxchildren': 50,
'maxrequests': 0,
'outlog': None,
'errlog': None,
}

def fastcgi_help(message=None):
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions django/utils/daemonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit a752a3d

Please sign in to comment.