Ticket #3047: generalize_flup.diff
File generalize_flup.diff, 2.9 KB (added by , 18 years ago) |
---|
-
django/core/servers/fastcgi.py
1 1 """ 2 FastCGI server that implements the WSGI protocol.2 FastCGI (or SCGI, or AJP1.3 ...) server that implements the WSGI protocol. 3 3 4 4 Uses the flup python package: http://www.saddi.com/software/flup/ 5 5 … … 18 18 __all__ = ["runfastcgi"] 19 19 20 20 FASTCGI_HELP = r"""runfcgi: 21 Run this project as a fastcgi application. To do this, the22 flup package from http://www.saddi.com/software/flup/ is23 required.21 Run this project as a fastcgi (or some other protocol supported 22 by flup) application. To do this, the flup package from 23 http://www.saddi.com/software/flup/ is required. 24 24 25 25 Usage: 26 26 django-admin.py runfcgi --settings=yourproject.settings [fcgi settings] 27 27 manage.py runfcgi [fcgi settings] 28 28 29 29 Optional Fcgi settings: (setting=value) 30 protocol=PROTOCOL fcgi, scgi, ajp, ... (default fcgi) 30 31 host=HOSTNAME hostname to listen on.. 31 32 port=PORTNUM port to listen on. 32 33 socket=FILE UNIX socket to listen on. … … 45 46 (for webservers which spawn your processes for you) 46 47 $ manage.py runfcgi method=threaded 47 48 48 Run a fastcgi server on a TCP host/port49 $ manage.py runfcgi method=prefork host=127.0.0.1 port=802549 Run a scgi server on a TCP host/port 50 $ manage.py runfcgi protocol=scgi method=prefork host=127.0.0.1 port=8025 50 51 51 52 Run a fastcgi server on a UNIX domain socket (posix platforms only) 52 53 $ manage.py runfcgi method=prefork socket=/tmp/fcgi.sock … … 58 59 """ 59 60 60 61 FASTCGI_OPTIONS = { 62 'protocol': 'fcgi', 61 63 'host': None, 62 64 'port': None, 63 65 'socket': None, … … 100 102 print >> sys.stderr, " installed flup, then make sure you have it in your PYTHONPATH." 101 103 return False 102 104 105 flup_module = 'server.' + options['protocol'] 106 103 107 if options['method'] in ('prefork', 'fork'): 104 from flup.server.fcgi_fork import WSGIServer105 108 wsgi_opts = { 106 109 'maxSpare': int(options["maxspare"]), 107 110 'minSpare': int(options["minspare"]), 108 111 'maxChildren': int(options["maxchildren"]), 109 112 'maxRequests': int(options["maxrequests"]), 110 113 } 114 flup_module += '_fork' 111 115 elif options['method'] in ('thread', 'threaded'): 112 from flup.server.fcgi import WSGIServer113 116 wsgi_opts = { 114 117 'maxSpare': int(options["maxspare"]), 115 118 'minSpare': int(options["minspare"]), … … 118 121 else: 119 122 return fastcgi_help("ERROR: Implementation must be one of prefork or thread.") 120 123 124 try: 125 WSGIServer = getattr(__import__('flup.' + flup_module, '', '', flup_module), 'WSGIServer') 126 except: 127 print "Can't import flup." + flup_module 128 return False 129 121 130 # Prep up and go 122 131 from django.core.handlers.wsgi import WSGIHandler 123 132