Gunicorn配置文件在哪里?

时间:2022-05-29 08:05:59

The gunicorn documentation talks about editing the config files, but I have no idea where it is.

gunicorn文档讨论了编辑配置文件,但我不知道它在哪里。

Probably a simple answer :) I'm on Amazon Linux AMI.

可能是一个简单的答案:)我在亚马逊Linux AMI上。

2 个解决方案

#1


21  

The answer is in the documentation of gunicorn. http://docs.gunicorn.org/en/latest/configure.html

答案在于gunicorn的文档。 http://docs.gunicorn.org/en/latest/configure.html

You can specify the config file with .ini or a python script.

您可以使用.ini或python脚本指定配置文件。

For example, from the django-skel project

例如,来自django-skel项目

"""gunicorn WSGI server configuration."""
from multiprocessing import cpu_count
from os import environ


def max_workers():    
    return cpu_count()


bind = '0.0.0.0:' + environ.get('PORT', '8000')
max_requests = 1000
worker_class = 'gevent'
workers = max_workers()

And you can run the server using

您可以使用运行服务器

gunicorn -c gunicorn.py.ini project.wsgi

Note that project.wsgi correspond to the location of your wsgi.

请注意,project.wsgi对应于wsgi的位置。

#2


4  

An example file is here: https://github.com/benoitc/gunicorn/blob/master/examples/example_config.py

这里有一个示例文件:https://github.com/benoitc/gunicorn/blob/master/examples/example_config.py

You can just comment out what you don't need and then point Gunicorn at it like so:

你可以只注释掉你不需要的内容,然后将Gunicorn指向它:

gunicorn -c config.py myproject:app

#1


21  

The answer is in the documentation of gunicorn. http://docs.gunicorn.org/en/latest/configure.html

答案在于gunicorn的文档。 http://docs.gunicorn.org/en/latest/configure.html

You can specify the config file with .ini or a python script.

您可以使用.ini或python脚本指定配置文件。

For example, from the django-skel project

例如,来自django-skel项目

"""gunicorn WSGI server configuration."""
from multiprocessing import cpu_count
from os import environ


def max_workers():    
    return cpu_count()


bind = '0.0.0.0:' + environ.get('PORT', '8000')
max_requests = 1000
worker_class = 'gevent'
workers = max_workers()

And you can run the server using

您可以使用运行服务器

gunicorn -c gunicorn.py.ini project.wsgi

Note that project.wsgi correspond to the location of your wsgi.

请注意,project.wsgi对应于wsgi的位置。

#2


4  

An example file is here: https://github.com/benoitc/gunicorn/blob/master/examples/example_config.py

这里有一个示例文件:https://github.com/benoitc/gunicorn/blob/master/examples/example_config.py

You can just comment out what you don't need and then point Gunicorn at it like so:

你可以只注释掉你不需要的内容,然后将Gunicorn指向它:

gunicorn -c config.py myproject:app