Ticket #6687: fastcgi-log-routing.diff

File fastcgi-log-routing.diff, 1.9 KB (added by Tamas Kemenczy, 17 years ago)
  • django/core/servers/fastcgi.py

     
    3838  daemonize=BOOL       whether to detach from terminal.
    3939  pidfile=FILE         write the spawned process-id to this file.
    4040  workdir=DIRECTORY    change to this directory when daemonizing
     41  outlog=FILE          write stdout to this file
     42  errlog=FILE          write stderr to this file
    4143
    4244Examples:
    4345  Run a "standard" fastcgi process on a file-descriptor
     
    6971    'minspare': 2,
    7072    'maxchildren': 50,
    7173    'maxrequests': 0,
     74    'outlog': None,
     75    'errlog': None,
    7276}
    7377
    7478def fastcgi_help(message=None):
     
    150154        else:
    151155            return fastcgi_help("ERROR: Invalid option for daemonize parameter.")
    152156
     157    daemon_kwargs = {}
     158    if options['outlog']:
     159        daemon_kwargs['out_log'] = options['outlog']
     160    if options['errlog']:
     161        daemon_kwargs['err_log'] = options['errlog']
     162
    153163    if daemonize:
    154164        from django.utils.daemonize import become_daemon
    155         become_daemon(our_home_dir=options["workdir"])
     165        become_daemon(our_home_dir=options["workdir"], **daemon_kwargs)
    156166
    157167    if options["pidfile"]:
    158168        fp = open(options["pidfile"], "w")
  • django/utils/daemonize.py

     
    2929        os.dup2(si.fileno(), sys.stdin.fileno())
    3030        os.dup2(so.fileno(), sys.stdout.fileno())
    3131        os.dup2(se.fileno(), sys.stderr.fileno())
     32        # set the custom file descriptors for python so they have correct buffering
     33        sys.stdout, sys.stderr = so, se
    3234else:
    3335    def become_daemon(our_home_dir='.', out_log=None, err_log=None):
    3436        """
Back to Top