Source

CherryPy / cherrypy / cherryd

Diff from to

File cherrypy/cherryd

 from cherrypy import Application
 
 def start(configfiles=None, daemonize=False, environment=None,
-          fastcgi=False, scgi=False, pidfile=None, imports=None):
+          fastcgi=False, scgi=False, pidfile=None, imports=None,
+          cgi=False):
     """Subscribe all engine plugins and start the engine."""
     sys.path = [''] + sys.path
     for i in imports or []:
     if hasattr(engine, "console_control_handler"):
         engine.console_control_handler.subscribe()
     
-    if fastcgi and scgi:
-        # fastcgi and scgi aren't allowed together.
-        cherrypy.log.error("fastcgi and scgi aren't allowed together.", 'ENGINE')
+    if (fastcgi and (scgi or cgi)) or (scgi and cgi):
+        cherrypy.log.error("You may only specify one of the cgi, fastcgi, and "
+                           "scgi options.", 'ENGINE')
         sys.exit(1)
-    elif fastcgi or scgi:
-        # Turn off autoreload when using fastcgi or scgi.
+    elif fastcgi or scgi or cgi:
+        # Turn off autoreload when using *cgi.
         cherrypy.config.update({'engine.autoreload_on': False})
         # Turn off the default HTTP server (which is subscribed by default).
         cherrypy.server.unsubscribe()
         if fastcgi:
             f = servers.FlupFCGIServer(application=cherrypy.tree,
                                        bindAddress=addr)
-        else:
+        elif scgi:
             f = servers.FlupSCGIServer(application=cherrypy.tree,
                                        bindAddress=addr)
+        else:
+            f = servers.FlupCGIServer(application=cherrypy.tree,
+                                      bindAddress=addr)
         s = servers.ServerAdapter(engine, httpserver=f, bind_addr=addr)
         s.subscribe()
     
                  help="start a fastcgi server instead of the default HTTP server")
     p.add_option('-s', action="store_true", dest='scgi',
                  help="start a scgi server instead of the default HTTP server")
+    p.add_option('-x', action="store_true", dest='cgi',
+                 help="start a cgi server instead of the default HTTP server")
     p.add_option('-i', '--import', action="append", dest='imports',
                  help="specify modules to import")
     p.add_option('-p', '--pidfile', dest='pidfile', default=None,
             sys.path.insert(0, p)
     
     start(options.config, options.daemonize,
-          options.environment, options.fastcgi, options.scgi, options.pidfile,
-          options.imports)
+          options.environment, options.fastcgi, options.scgi,
+          options.pidfile, options.imports, options.cgi)