Commit a752a3d4 authored by Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss
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
parent f0dec08c
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -37,7 +37,9 @@ Optional Fcgi settings: (setting=value)
  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 @@ FASTCGI_OPTIONS = {
    '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")
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ if os.name == 'posix':
        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):
        """