Ticket #6994: 6994.patch
File 6994.patch, 2.3 KB (added by , 17 years ago) |
---|
-
django/core/servers/fastcgi.py
40 40 workdir=DIRECTORY change to this directory when daemonizing. 41 41 outlog=FILE write stdout to this file. 42 42 errlog=FILE write stderr to this file. 43 umask=UMASK umask to use when daemonizing (default 027). 43 44 44 45 Examples: 45 46 Run a "standard" fastcgi process on a file-descriptor … … 73 74 'maxrequests': 0, 74 75 'outlog': None, 75 76 'errlog': None, 77 'umask': None, 76 78 } 77 79 78 80 def fastcgi_help(message=None): … … 159 161 daemon_kwargs['out_log'] = options['outlog'] 160 162 if options['errlog']: 161 163 daemon_kwargs['err_log'] = options['errlog'] 164 if options['umask']: 165 daemon_kwargs['umask'] = int(options['umask']) 162 166 163 167 if daemonize: 164 168 from django.utils.daemonize import become_daemon -
django/utils/daemonize.py
2 2 import sys 3 3 4 4 if os.name == 'posix': 5 def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null'): 5 def become_daemon(our_home_dir='.', out_log='/dev/null', 6 err_log='/dev/null', umask=027): 6 7 "Robustly turn into a UNIX daemon, running in our_home_dir." 7 8 # First fork 8 9 try: … … 13 14 sys.exit(1) 14 15 os.setsid() 15 16 os.chdir(our_home_dir) 16 os.umask( 0)17 os.umask(umask) 17 18 18 19 # Second fork 19 20 try: … … 32 33 # Set custom file descriptors so that they get proper buffering. 33 34 sys.stdout, sys.stderr = so, se 34 35 else: 35 def become_daemon(our_home_dir='.', out_log=None, err_log=None ):36 def become_daemon(our_home_dir='.', out_log=None, err_log=None, umask=027): 36 37 """ 37 38 If we're not running under a POSIX system, just simulate the daemon 38 39 mode by doing redirections and directory changing. 39 40 """ 40 41 os.chdir(our_home_dir) 41 os.umask( 0)42 os.umask(umask) 42 43 sys.stdin.close() 43 44 sys.stdout.close() 44 45 sys.stderr.close()