Ejemplo n.º 1
0
def main():  # pragma: no cover
    """Run server from the command line."""
    import multiprocessing

    from docopt import docopt
    from gunicorn.app.pasterapp import paste_server

    arguments = docopt(__doc__, version="Pydap %s" % __version__)

    # init templates?
    if arguments["--init"]:
        init(arguments["--init"])
        return

    # create pydap app
    data, templates = arguments["--data"], arguments["--templates"]
    app = DapServer(data, templates)

    # configure app so that is reads static assets from the template directory
    # or from the package
    if templates and os.path.exists(os.path.join(templates, "static")):
        static = os.path.join(templates, "static")
    else:
        static = ("pydap.wsgi", "templates/static")
    app = StaticMiddleware(app, static)

    # configure WSGI server
    workers = multiprocessing.cpu_count() * 2 + 1
    paste_server(
        app,
        host=arguments["--bind"],
        port=int(arguments["--port"]),
        workers=workers,
        worker_class=arguments["--worker-class"])
Ejemplo n.º 2
0
Archivo: runapp.py Proyecto: grze/koala
def main():
    ini_file = 'config:console.ini'
    port = int(os.environ.get("KOALA_PORT", 8888))
    workers = multiprocessing.cpu_count() * 2 + 1
    worker_class = 'gevent'
    app = loadapp(ini_file, relative_to='.')
    paste_server(app, host='0.0.0.0', port=port, workers=workers, worker_class=worker_class)
Ejemplo n.º 3
0
from paste.deploy import loadapp
from gunicorn.app.pasterapp import paste_server
from pylons101.config.server import MyWorker


if __name__ == '__main__':
    app = loadapp('config:development.ini', relative_to='.')
    paste_server(app, host='0.0.0.0', port=5000, workers=1, worker_class=MyWorker, timeout=0)
Ejemplo n.º 4
0
import os

from paste.deploy import loadapp
from gunicorn.app.pasterapp import paste_server

if __name__ == "__main__":
    port = int(os.environ.get("PORT", 5000))
    wsgi_app = loadapp('config:production.ini', relative_to='.')
    paste_server(wsgi_app, host='0.0.0.0', port=port)
Ejemplo n.º 5
0
    def on_open(self):
        self.manager.broadcast("Someone joined.")

    def on_message(self, message):
        self.manager.broadcast(message)

    def on_close(self):
        self.manager.broadcast("Someone left.")


if __name__ == '__main__':
    """ Simple sockjs chat """
    from pyramid.config import Configurator
    from pyramid_sockjs.paster import gevent_server_runner

    config = Configurator()
    config.include('pyramid_sockjs')

    config.add_sockjs_route(prefix='/__sockjs__', session=ChatSession)

    config.add_route('root', '/')
    config.add_view(route_name='root', renderer='__main__:chat.pt')

    app = config.make_wsgi_app()

    if len(sys.argv) > 1 and (sys.argv[1] == '-g'):
        from gunicorn.app.pasterapp import paste_server
        paste_server(app, port=8080, worker_class='gevent', workers=1)
    else:
        gevent_server_runner(app, {}, host='127.0.0.1')
Ejemplo n.º 6
0
    websocket.TIMING = 0.1
    jsonp.timing = 0.1
    PollingTransport.timing = 0.2

    config = Configurator()
    config.include('pyramid_sockjs')

    config.add_sockjs_route('echo', '/echo', session=EchoSession)
    config.add_sockjs_route('wsoff',
                            '/disabled_websocket_echo',
                            session=EchoSession,
                            disable_transports=('websocket', ))

    config.add_sockjs_route('close', '/close', session=CloseSession)
    config.add_sockjs_route('broadcast',
                            '/broadcast',
                            session=BroadcastSession)

    config.add_sockjs_route('cookie',
                            '/cookie_needed_echo',
                            session=EchoSession,
                            cookie_needed=True)

    app = config.make_wsgi_app()

    if len(sys.argv) > 1 and (sys.argv[1] == '-g'):
        from gunicorn.app.pasterapp import paste_server
        paste_server(app, port=8081, worker_class='gevent', workers=1)
    else:
        gevent_server_runner(app, {}, **{'host': '127.0.0.1', 'port': '8081'})