コード例 #1
0
def gunicorn(ctx, debug=None, environment='production', port=8000, workers=4):
    """
    Run application using gunicorn for production deploys.

    It assumes that static media is served by a reverse proxy.
    """

    from gunicorn.app.wsgiapp import run as run_gunicorn

    env = {
        'DISABLE_DJANGO_DEBUG_TOOLBAR': str(not debug),
        'PYTHONPATH': 'src',
        'DJANGO_ENVIRONMENT': environment,
    }
    if debug is not None:
        env['DJANGO_DEBUG'] = str(debug).lower()
    os.environ.update(env)

    args = [
        'ej.wsgi',
        '-w',
        str(workers),
        '-b',
        f'0.0.0.0:{port}',
        '--error-logfile=-',
        '--access-logfile=-',
        '--log-level',
        'info',
    ]
    sys.argv = ['gunicorn', *args]
    run_gunicorn()
コード例 #2
0
def gunicorn(ctx, debug=None, environment="production", port=8000, workers=4):
    """
    Run application using gunicorn for production deploys.

    It assumes that static media is served by a reverse proxy.
    """

    from gunicorn.app.wsgiapp import run as run_gunicorn

    directory = ""

    env = {
        "DISABLE_DJANGO_DEBUG_TOOLBAR": str(not debug),
        "PYTHONPATH": "src",
        "DJANGO_ENVIRONMENT": environment,
    }
    if debug is not None:
        env["DJANGO_DEBUG"] = str(debug).lower()
    os.environ.update(env)
    args = [
        "ej.wsgi",
        "-w",
        str(workers),
        "-b",
        f"0.0.0.0:{port}",
        "--error-logfile=-",
        "--access-logfile=-",
        "--log-level",
        "info",
        f"--pythonpath={directory}/src",
    ]
    sys.argv = ["gunicorn", *args]
    run_gunicorn()
コード例 #3
0
ファイル: cli.py プロジェクト: 2890841438/index.py
def start(workers, worker_class, daemon, configuration, application):
    from gunicorn.app.wsgiapp import run as run_gunicorn

    command = (
        "gunicorn"
        + f" -k {worker_class}"
        + f" --bind {serve_config.HOST}:{serve_config.PORT}"
        + f" --chdir {os.getcwd()}"
        + f" --workers {workers}"
        + f" --pid {os.path.join(os.getcwd(), '.pid')}"
        + f" --log-level {serve_config.LOG_LEVEL}"
    )
    args = command.split(" ")
    if daemon:
        args.extend("-D --log-file log.index".split(" "))
    if serve_config.AUTORELOAD:
        args.append("--reload")
    if configuration:
        args.append("-c")
        args.append(configuration.strip())
    args.append(application)

    sys.argv = args
    run_gunicorn()