예제 #1
0
 def appmain(self, isExit):    
     """
     Called to run inside its own thread once twisted has taken over 
     the main loop.
     
     """
     app = self.appmainSetup()
     self.log.info("appmain: Serving webapp")
     server_runner(app, self.globalConf, **self.serverConf)
예제 #2
0
def paste_server_selector(wsgi_app, global_config=None, **app_config):
    """
    Select between gunicorn and paste depending on what ia available
    """
    # See if we can import the gunicorn server...
    # otherwise we'll use the paste server
    try:
        import gunicorn
    except ImportError:
        gunicorn = None

    if gunicorn is None:
        # use paste
        from paste.httpserver import server_runner

        cleaned_app_config = dict(
            [(key, app_config[key])
             for key in app_config
             if key in ["host", "port", "handler", "ssl_pem", "ssl_context",
                        "server_version", "protocol_version", "start_loop",
                        "daemon_threads", "socket_timeout", "use_threadpool",
                        "threadpool_workers", "threadpool_options",
                        "request_queue_size"]])

        return server_runner(wsgi_app, global_config, **cleaned_app_config)
    else:
        # use gunicorn
        from gunicorn.app.pasterapp import PasterServerApplication
        return PasterServerApplication(wsgi_app, global_config, **app_config)
예제 #3
0
def paste_server_selector(wsgi_app, global_config=None, **app_config):
    """
    Select between gunicorn and paste depending on what ia available
    """
    # See if we can import the gunicorn server...
    # otherwise we'll use the paste server
    try:
        import gunicorn
    except ImportError:
        gunicorn = None

    if gunicorn is None:
        # use paste
        from paste.httpserver import server_runner

        cleaned_app_config = dict([
            (key, app_config[key]) for key in app_config if key in [
                "host", "port", "handler", "ssl_pem", "ssl_context",
                "server_version", "protocol_version", "start_loop",
                "daemon_threads", "socket_timeout", "use_threadpool",
                "threadpool_workers", "threadpool_options",
                "request_queue_size"
            ]
        ])

        return server_runner(wsgi_app, global_config, **cleaned_app_config)
    else:
        # use gunicorn
        from gunicorn.app.pasterapp import PasterServerApplication
        return PasterServerApplication(wsgi_app, global_config, **app_config)
예제 #4
0
import os
from paste import httpserver
from paste.deploy import loadapp

if __name__ == '__main__':
    config = '/home/lj/my_libcloud/WSGI/proxy-server.conf'
    appname = 'main'
    global_conf = {}
    wsgi_app = loadapp('config:%s'%os.path.abspath(config),appname)
    httpserver.server_runner(wsgi_app,global_conf)