コード例 #1
0
ファイル: _cpengine.py プロジェクト: thraxil/gtreed
    def start(self):
        """Start the application server engine."""
        self.state = STARTING
        self.interrupt = None

        conf = cherrypy.config.get

        # Autoreload. Note that, if we're not starting our own HTTP server,
        # autoreload could do Very Bad Things when it calls sys.exit, but
        # deployers will just have to be educated and responsible for it.
        if conf("autoreload.on", False):
            try:
                freq = conf("autoreload.frequency", 1)
                autoreload.main(self._start, freq=freq)
            except KeyboardInterrupt:
                cherrypy.log("<Ctrl-C> hit: shutting down autoreloader", "ENGINE")
                self.stop()
            except SystemExit:
                cherrypy.log("SystemExit raised: shutting down autoreloader", "ENGINE")
                self.stop()
                # We must raise here: if this is a process spawned by
                # autoreload, then it must return its error code to
                # the parent.
                raise
            return

        self._start()
コード例 #2
0
ファイル: _cpserver.py プロジェクト: bieschke/nuffle
 def start(self, initOnly=False, serverClass=_missing):
     """Main function. MUST be called from the main thread.
     
     Set initOnly to True to keep this function from blocking.
     Set serverClass to None to skip starting any HTTP server.
     """
     self.state = STARTING
     self.interrupt = None
     
     conf = cherrypy.config.get
     
     if serverClass is _missing:
         serverClass = conf("server.class", _missing)
     if serverClass is _missing:
         import _cpwsgi
         serverClass = _cpwsgi.WSGIServer
     elif serverClass and isinstance(serverClass, basestring):
         # Dynamically load the class from the given string
         serverClass = cherrypy._cputil.attributes(serverClass)
     
     self.blocking = not initOnly
     self.httpserverclass = serverClass
     
     # Autoreload, but check serverClass. If None, we're not starting
     # our own webserver, and therefore could do Very Bad Things when
     # autoreload calls sys.exit.
     if serverClass is not None:
         defaultOn = (conf("server.environment") == "development")
         if conf('autoreload.on', defaultOn):
             try:
                 autoreload.main(self._start)
             except KeyboardInterrupt:
                 cherrypy.log("<Ctrl-C> hit: shutting down autoreloader", "HTTP")
                 self.stop()
             except SystemExit:
                 cherrypy.log("SystemExit raised: shutting down autoreloader", "HTTP")
                 self.stop()
                 # We must raise here: if this is a process spawned by
                 # autoreload, then it must return its error code to
                 # the parent.
                 raise
             return
     
     self._start()