Example #1
0
    def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()
        app.app_uri = 'lemur:create_app(config="{0}")'.format(kwargs.get('config'))

        return app.run()
Example #2
0
    def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()
        app.app_uri = 'lemur:create_app(config="{0}")'.format(kwargs.get('config'))

        return app.run()
Example #3
0
    def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()

        app.app_uri = 'aardvark:create_app()'
        return app.run()
Example #4
0
    def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()

        # run startup tasks on an app like object
        validate_conf(current_app, REQUIRED_VARIABLES)

        app.app_uri = 'lemur:create_app(config="{0}")'.format(current_app.config.get('CONFIG_PATH'))

        return app.run()
Example #5
0
    def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()

        # run startup tasks on an app like object
        validate_conf(current_app, REQUIRED_VARIABLES)

        app.app_uri = 'lemur:create_app(config="{0}")'.format(current_app.config.get('CONFIG_PATH'))

        return app.run()
Example #6
0
    def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()

        # run startup tasks on a app like object
        pre_app = create_app(kwargs.get('config'))
        validate_conf(pre_app, REQUIRED_VARIABLES)

        app.app_uri = 'lemur:create_app(config="{0}")'.format(
            kwargs.get('config'))

        return app.run()
Example #7
0
    def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()

        # run startup tasks on an app like object
        validate_conf(current_app, REQUIRED_VARIABLES)

        app.app_uri = 'lemur:create_app(config_path="{0}")'.format(
            current_app.config.get("CONFIG_PATH"))

        log_config_dict = current_app.config.get("LOG_CONFIG_DICT")
        if log_config_dict:
            app.cfg.set("logconfig_dict", log_config_dict)

        return app.run()
Example #8
0
 def handle(self, *args, **options):
     # some argv trickery to reuse max of gunicorn wsgiapp
     # prefer this to a more programmatic way
     sys.argv = sys.argv[1:]
     app = settings.WSGI_APPLICATION.rsplit('.', 1)
     sys.argv.append(':'.join(app))
     WSGIApplication().run()
Example #9
0
def run():
    """\
    The ``gunicorn`` command line runner for launching Gunicorn with
    generic WSGI applications.
    """
    from gunicorn.app.wsgiapp import WSGIApplication
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
def runserver(ctx, bind=None, develop=False):
    """Start Admin server."""
    if bind:
        host, port = bind.split(':')
    else:
        host, port = settings.admin.host, settings.admin.port

    if develop:
        executable = 'gunicorn'

        args = [executable, 'admin.app:app']
        args += ['-b', '{}:{}'.format(host, port)]
        args += ['--timeout', '600']
        args += ['--reload']

        g_app = WSGIApplication()
        g_app.run()
    else:
        app.run(debug=settings.debug, host=host, port=int(port))
        return
Example #11
0
def wsgi_server(host, port, workers, timeout):
    wsgi_app = WSGIApplication()
    wsgi_app.load_wsgiapp = lambda: app
    wsgi_app.cfg.set('bind', '%s:%s' % (host, port))
    wsgi_app.cfg.set('workers', workers)
    wsgi_app.cfg.set('timeout', timeout)
    wsgi_app.cfg.set('pidfile', None)
    wsgi_app.cfg.set('accesslog', '-')
    wsgi_app.cfg.set('errorlog', '-')
    wsgi_app.chdir()
    wsgi_app.run()
Example #12
0
def deploy():
    """
    Deploy app
    """
    app.config.update(DEBUG=False, TESTING=False)

    try:
        os.mkdir("log")
    except BaseException:
        pass

    for file_name in ["log/error.log", "log/access.log"]:
        if not os.path.exists(file_name):
            os.system("touch " + file_name)

    from gunicorn.app.wsgiapp import WSGIApplication
    guni_app = WSGIApplication()
    guni_app.app_uri = 'dueros:app'

    options = {
        'workers': 4,
        'accesslog': 'log/access.log',
        'errorlog': 'log/error.log',
        'loglevel': 'info',
        'bind': '127.0.0.1:8000',
    }

    config = dict([(key, value) for key, value in iteritems(options)])

    for key, value in iteritems(config):
        guni_app.cfg.set(key, value)

    print(
        "=======================================================================\n"
        "============================ start gunicorn ===========================\n"
        "======================================================================="
    )
    return guni_app.run()
Example #13
0
    def handle(self, *args):
        try:
            from gunicorn.app.wsgiapp import WSGIApplication
        except ModuleNotFoundError as exc:
            raise ModuleNotFoundError("Gunicorn not found. Please install it (pip install gunicorn).") from exc

        _sys_argv_backup, sys.argv = sys.argv, [
            sys.argv[1],
            "config.wsgi",
            *sys.argv[2:],
        ]
        try:
            WSGIApplication("django-zero %(prog)s [OPTIONS]").run()
        finally:
            sys.argv = _sys_argv_backup
Example #14
0
def run_gunicorn():
    config = get_config()

    # Early throw-away parsing of gunicorn config, as we need to decide
    # whether to enable prometheus multiprocess before we start importing
    from gunicorn.app.wsgiapp import WSGIApplication
    g_cfg = WSGIApplication().cfg

    # configure prometheus_client early as possible
    if pkg_is_installed('prometheus-client'):
        if g_cfg.workers > 1 or 'prometheus_multiproc_dir' in os.environ:
            from talisker.prometheus import setup_prometheus_multiproc
            async_workers = ('gevent', 'eventlet')
            # must be done before prometheus_client is imported *anywhere*
            setup_prometheus_multiproc(
                any(n in g_cfg.worker_class_str for n in async_workers))
    try:
        from gunicorn.workers.ggevent import GeventWorker
        from talisker.context import enable_gevent_context
    except Exception:
        pass
    else:
        if g_cfg.worker_class == GeventWorker:
            enable_gevent_context()

    try:
        from gunicorn.workers.geventlet import EventletWorker
        from talisker.context import enable_eventlet_context
    except Exception:
        pass
    else:
        if g_cfg.worker_class == EventletWorker:
            enable_eventlet_context()

    initialise()

    import talisker.gunicorn

    if pkg_is_installed('celery'):
        import talisker.celery
        talisker.celery.enable_signals()

    app = talisker.gunicorn.TaliskerApplication(
        "%(prog)s [OPTIONS] [APP_MODULE]", config.devel, config.debuglog)
    clear_context()
    return app.run()
Example #15
0
def runserver(host='0.0.0.0', port=6000, workers=1):
    """Run the app with Gunicorn."""

    if app.debug:
        app.run(host, int(port), use_reloader=False)
    else:
        gunicorn = WSGIApplication()
        gunicorn.load_wsgiapp = lambda: app
        gunicorn.cfg.set('bind', '%s:%s' % (host, port))
        gunicorn.cfg.set('workers', workers)
        gunicorn.cfg.set('pidfile', None)
        # gunicorn.cfg.set('worker_class', 'gunicorn.workers.ggevent.GeventWorker')
        gunicorn.cfg.set('accesslog', '-')
        gunicorn.cfg.set('errorlog', '-')
        gunicorn.cfg.set('timeout', 300)
        gunicorn.chdir()
        gunicorn.run()
Example #16
0
def start_gunicorn(hostname, port, open_browser):
    import sys
    try:
        from gunicorn.app.wsgiapp import WSGIApplication
    except ImportError:
        # If gunicorn isn't installed fall back to the copy in ./dependencies
        sys.path.append(os.path.join(os.path.dirname(__file__), "dependencies"))
        from gunicorn.app.wsgiapp import WSGIApplication

    if open_browser:
        browser('localhost', port, False)
    
    sys.argv = [sys.argv[0]] + ["--bind", "{}:{}".format(hostname, port),
                                "--workers", "1",
                                "--threads", "1",
                                "uwsgi:app",
                                __file__]
    
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
Example #17
0
def runserver(host=None, port=None, workers=None):
    """Runs the app within Gunicorn."""
    host = host or app.config.get('HTTP_HOST') or '0.0.0.0'
    port = port or app.config.get('HTTP_PORT') or 5000
    workers = workers or app.config.get('HTTP_WORKERS') or 1
    use_evalex = app.config.get('USE_EVALEX', app.debug)

    if app.debug:
        app.run(host, int(port), use_evalex=use_evalex)
    else:
        gunicorn = WSGIApplication()
        gunicorn.load_wsgiapp = lambda: app
        gunicorn.cfg.set('bind', '%s:%s' % (host, port))
        gunicorn.cfg.set('workers', workers)
        gunicorn.cfg.set('pidfile', None)
        gunicorn.cfg.set('accesslog', '-')
        gunicorn.cfg.set('errorlog', '-')
        gunicorn.chdir()
        gunicorn.run()
Example #18
0
def http(host='127.0.0.1', port=5000, workers=None):
    """Runs the app within Gunicorn."""
    workers = workers or app.config.get('WORKERS') or 1

    if app.debug:
        app.run(host, int(port))
    else:
        gunicorn = WSGIApplication()
        gunicorn.load_wsgiapp = lambda: app
        gunicorn.cfg.set('bind', '%s:%s' % (host, port))
        gunicorn.cfg.set('workers', workers)
        gunicorn.cfg.set('pidfile', None)
        gunicorn.cfg.set('accesslog', '-')
        gunicorn.cfg.set('errorlog', '-')
        gunicorn.chdir()
        gunicorn.run()
Example #19
0
 def run(self, *args, **kwargs):
     from gunicorn.app.wsgiapp import WSGIApplication
     app = WSGIApplication()
     app.app_uri = 'manage:app'
     return app.run()
Example #20
0
def run_app(_args):
    from gunicorn.app.wsgiapp import WSGIApplication
    wsgi_app = WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]")
    wsgi_app.app_uri = 'gam.app:create_app()'
    wsgi_app.cfg.set('reload', True)
    wsgi_app.run()
from gunicorn.app.wsgiapp import WSGIApplication

w = WSGIApplication()
w.run()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from gunicorn.app.wsgiapp import WSGIApplication

if __name__ == '__main__':
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
Example #23
0
#!/usr/bin/env python
from gunicorn.app.wsgiapp import WSGIApplication

# --bind 0.0.0.0:8080 -w 1 -k uvicorn.workers.UvicornWorker -t 600 ranker.server:APP
app = WSGIApplication()

app.run()
 def app(self):
     from gunicorn.app.wsgiapp import WSGIApplication
     WSGIApplication().run()
Example #25
0
 def run(self, *args, **kwargs):
     from gunicorn.app.wsgiapp import WSGIApplication
     app = WSGIApplication()
     app.app_uri = 'manage:app'
     return app.run()
Example #26
0
 def start_webserver(self):
     app = WSGIApplication()
     app.app_uri = 'cerberus.webserver:app'
     return app.run()
Example #27
0
# coding: utf-8
import sys
from gunicorn.app.wsgiapp import WSGIApplication

__author__ = 'banxi'

if __name__ == '__main__':
    app = WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]")
    sys.exit(app.run())