Changeset 2022
- Timestamp:
- 07/22/08 11:16:58
- Files:
-
- trunk/cherrypy/cherryd (modified) (5 diffs)
- trunk/cherrypy/process/servers.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/cherryd
r2018 r2022 9 9 10 10 def start(configfiles=None, daemonize=False, environment=None, 11 fastcgi=False, pidfile=None, imports=None):11 fastcgi=False, scgi=False, pidfile=None, imports=None): 12 12 """Subscribe all engine plugins and start the engine.""" 13 sys.path = [''] + sys.path 13 14 for i in imports or []: 14 15 exec "import %s" % i … … 36 37 engine.console_control_handler.subscribe() 37 38 38 if fastcgi: 39 # Turn off autoreload when using fastcgi. 39 if fastcgi and scgi: 40 # fastcgi and scgi aren't allowed together. 41 cherrypy.log.error("fastcgi and scgi aren't allowed together.", 'ENGINE') 42 sys.exit(1) 43 elif fastcgi or scgi: 44 # Turn off autoreload when using fastcgi or scgi. 40 45 cherrypy.config.update({'engine.autoreload_on': False}) 41 46 … … 46 51 bindAddress = sock_file 47 52 else: 48 fastcgi_port = cherrypy.config.get('server.socket_port', 4000) 49 fastcgi_bindaddr = cherrypy.config.get('server.socket_host', '0.0.0.0') 50 bindAddress = (fastcgi_bindaddr, fastcgi_port) 51 f = servers.FlupFCGIServer(application=cherrypy.tree, bindAddress=bindAddress) 53 flup_port = cherrypy.config.get('server.socket_port', 4000) 54 flup_bindaddr = cherrypy.config.get('server.socket_host', '0.0.0.0') 55 bindAddress = (flup_bindaddr, flup_port) 56 if fastcgi: 57 f = servers.FlupFCGIServer(application=cherrypy.tree, bindAddress=bindAddress) 58 else: 59 f = servers.FlupSCGIServer(application=cherrypy.tree, bindAddress=bindAddress) 52 60 s = servers.ServerAdapter(engine, httpserver=f, bind_addr=bindAddress) 53 61 s.subscribe() … … 75 83 p.add_option('-f', action="store_true", dest='fastcgi', 76 84 help="start a fastcgi server instead of the default HTTP server") 85 p.add_option('-s', action="store_true", dest='scgi', 86 help="start a scgi server instead of the default HTTP server") 77 87 p.add_option('-i', '--import', action="append", dest='imports', 78 88 help="specify modules to import") … … 82 92 83 93 start(options.config, options.daemonize, 84 options.environment, options.fastcgi, options. pidfile,94 options.environment, options.fastcgi, options.scgi, options.pidfile, 85 95 options.imports) 86 96 trunk/cherrypy/process/servers.py
r1974 r2022 136 136 # for signum,handler in self._oldSIGs: 137 137 # AttributeError: 'WSGIServer' object has no attribute '_oldSIGs' 138 self.fcgiserver._installSignalHandlers = lambda: None 138 139 self.fcgiserver._oldSIGs = [] 139 140 self.ready = False … … 151 152 # Force all worker threads to die off. 152 153 self.fcgiserver._threadPool.maxSpare = 0 154 155 156 class FlupSCGIServer(object): 157 """Adapter for a flup.server.scgi.WSGIServer.""" 158 159 def __init__(self, *args, **kwargs): 160 from flup.server.scgi import WSGIServer 161 self.scgiserver = WSGIServer(*args, **kwargs) 162 # TODO: report this bug upstream to flup. 163 # If we don't set _oldSIGs on Windows, we get: 164 # File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py", 165 # line 108, in run 166 # self._restoreSignalHandlers() 167 # File "C:\Python24\Lib\site-packages\flup\server\threadedserver.py", 168 # line 156, in _restoreSignalHandlers 169 # for signum,handler in self._oldSIGs: 170 # AttributeError: 'WSGIServer' object has no attribute '_oldSIGs' 171 self.scgiserver._installSignalHandlers = lambda: None 172 self.scgiserver._oldSIGs = [] 173 self.ready = False 174 175 def start(self): 176 """Start the SCGI server.""" 177 self.ready = True 178 self.scgiserver.run() 179 180 def stop(self): 181 """Stop the HTTP server.""" 182 self.ready = False 183 # Forcibly stop the scgi server main event loop. 184 self.scgiserver._keepGoing = False 185 # Force all worker threads to die off. 186 self.scgiserver._threadPool.maxSpare = 0 153 187 154 188

