community.general.gunicorn 模块 – 使用各种设置运行 gunicorn
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.general
。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在剧本中使用它,请指定: community.general.gunicorn
。
概要
使用指定参数启动 gunicorn。支持 gunicorn 配置的常见设置。有关其他配置,请使用配置文件。请参阅 https://gunicorn-docs.readthedocs.io/en/latest/settings.html 获取更多选项。建议始终使用 chdir 选项以避免应用程序位置出现问题。
要求
执行此模块的主机需要以下要求。
gunicorn
参数
参数 |
注释 |
---|---|
应用程序模块。名称指的是应该在指定的模块中找到的 WSGI 可调用对象。 |
|
在加载应用程序之前更改到指定的目录。 |
|
gunicorn 配置文件的路径。 |
|
用于 PID 文件的文件名。如果未设置且未在配置文件中找到,则会创建一个临时 pid 文件以检查 gunicorn 是否成功运行。 |
|
将工作进程切换为以该用户身份运行。 |
|
virtualenv 目录的路径。 |
|
要使用的 worker 类型。默认类 (sync) 应该能够处理大多数“正常”类型的负载。 选项
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持:不支持 |
可以在 |
|
支持:不支持 |
在差异模式下,将返回有关已更改内容(或可能需要在 |
备注
注意
如果在配置文件中未指定,则会在 /tmp 目录中创建一个临时错误日志。请确保您对 /tmp 目录具有写入权限。不是必需的,但将有助于您识别任何配置问题。
示例
- name: Simple gunicorn run example
community.general.gunicorn:
app: 'wsgi'
chdir: '/workspace/example'
- name: Run gunicorn on a virtualenv
community.general.gunicorn:
app: 'wsgi'
chdir: '/workspace/example'
venv: '/workspace/example/venv'
- name: Run gunicorn with a config file
community.general.gunicorn:
app: 'wsgi'
chdir: '/workspace/example'
conf: '/workspace/example/gunicorn.cfg'
- name: Run gunicorn as ansible user with specified pid and config file
community.general.gunicorn:
app: 'wsgi'
chdir: '/workspace/example'
conf: '/workspace/example/gunicorn.cfg'
venv: '/workspace/example/venv'
pid: '/workspace/example/gunicorn.pid'
user: 'ansible'
返回值
常见返回值已记录在 此处,以下是此模块独有的字段
键 |
描述 |
---|---|
gunicorn 的进程 ID 返回:已更改 示例: |