- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我对 Flask/Nginx/Gunicorn 还是很陌生,因为这只是我使用该组合的第二个站点。我根据 Miguel Grinberg 的 tutorial 创建了一个网站所以我的文件结构与本教程中的完全相同。
在我以前的 Flask 应用程序中,我的应用程序位于一个名为 app.py
的文件中,所以当我使用 Gunicorn 时,我只调用了 gunicorn app:app
现在我的新应用程序被拆分成多个文件,我使用文件 run.py
来启动应用程序,但我不确定现在应该如何调用 Gunicorn。我已经阅读了其他问题和教程,但它们没有用。当我运行 gunicorn run:app
并尝试访问该站点时,出现 502 Bad Gateway 错误。
我认为我的问题更多的是 Gunicorn 而不是 Nginx 或 Flask,因为只要我输入 ./run.py
网站就可以正常运行。无论如何,我在下面包含了我的 Nginx 配置和其他一些文件。非常感谢您的帮助!
文件:run.py
#!flask/bin/python
from app import app
from werkzeug.contrib.fixers import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app)
app.run(debug = True, port=8001)
文件:app/views.py
from app import app
@app.route('/')
@app.route('/index')
def index():
posts = Post.query.order_by(Post.id.desc()).all()
return render_template('index.html', posts=posts)
文件:nginx.conf
server {
listen 80;
server_name example.com;
root /var/www/example.com/public_html/app;
access_log /var/www/example.com/logs/access.log;
error_log /var/www/example.com/logs/error.log;
client_max_body_size 2M;
location / {
try_files $uri @gunicorn_proxy;
}
location @gunicorn_proxy {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8001;
}
}
最佳答案
当 gunicorn 导入 app.py
时,开发服务器正在运行。您只希望在直接执行文件时发生这种情况(例如,python app.py
)。
#!flask/bin/python
from app import app
from werkzeug.contrib.fixers import ProxyFix
app.wsgi_app = ProxyFix(app.wsgi_app)
if __name__ == '__main__':
# You don't need to set the port here unless you don't want to use 5000 for development.
app.run(debug=True)
完成此更改后,您应该能够使用 gunicorn run:app
运行应用程序。请注意,gunicorn 默认使用端口 8000。如果您希望在备用端口(例如 8001)上运行,则需要使用 gunicorn -b :8001 run:app
进行指定。
关于python - Nginx、Flask、Gunicorn 502 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26211267/
我尝试了几乎所有命令来杀死 gunicorn 服务器。但没有任何效果。我怎样才能杀死这些进程并释放 80 端口 12652 ? Ss 0:00 sudo gunicorn -b
我正在使用 Apache Airflow,发现 gunicorn-error.log 的大小在 5 个月内增长了超过 50 GB。大多数日志消息都是 INFO 级别的日志,例如: [2018-05-1
我正在使用 在 Digital Ocean 上运行 django gunicorn 和 nginx . Gunicorn 用于为静态文件提供 django 和 nginx。 通过网站上传文件后,我无法
我正在使用 Django 1.8,我想用 gunicorn 运行我的应用程序。 我可以从命令行绑定(bind)到我的 IP 运行它: gunicorn myapp.wsgi:application -
我们正在使用 https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker FastAPI 并且能够使用 gunicorn 日志文件自定义我们
我在 docker 上的 centos7 上运行 Airflow 1.8,但我的网络服务器无法访问浏览器。我通过pip2.7安装了airflow。 Flower ui 显示良好,initdb 运行连接
gunicorn.service cannot open WorkingDirectory and the gunicorn executable. I think it's about per
任何想法为什么我的 gunicorn 服务器无法启动? jeffy@originaldjangster:~$ sudo /home/jeffy/django_files/django_test_ven
我已经安装了gunicorn,但是没有找到gunicorn命令: # pip3.4 install gunicorn Requirement already satisfied (use --upgr
我在有监督的ginicorn部署我的django项目。 我在virtualenv中安装了gunicorn,添加到INSTALL_APPS中。 命令./manage.py run_gunicorn -b
我成功安装了gunicorn: remote: -----> Removing .DS_Store files remote: -----> Python app detected remote: -
Systemd 和 Gunicorn 需要某种 wsgi 文件作为 ExecStart 的最后一个参数:http://docs.gunicorn.org/en/latest/deploy.html?h
我正在尝试将基本应用程序部署到 Amazon EC2使用 Django , Gunicorn , 和 Nginx .我有应用 git clone进入我的AWS Ubuntu实例并正在运行 Django
在更新为使用小型模型中的 spacy_en_core_web_lg 后,我的 fastapi 服务器内存不足。 当运行 fastapi 时,会生成 4 个 gunicorn worker,并且根据内存
我有一个基于这个的 ansible 配置虚拟机 https://github.com/jcalazan/ansible-django-stack但出于某种原因,尝试启动 Gunicorn 会出现以下错
我关注 this如何在 Ubuntu 18.04 指南中使用 Postgres、Nginx 和 Gunicorn 设置 Django。 我创建了以下文件 .socket sudo nano /etc/
我正在尝试按照此 [链接][1] 在 Digital Ocean 上部署简单的 Django 应用程序用 gunicorn 实现它的抛出错误 gunicorn.service: Failed with
这里我想问你,用python运行gunicorn uvicorn,和默认从tiangolo有什么区别? 我尝试使用 JMeter 对这些进行压力测试具有线程属性: 从这些,我得到了结果:: 从上面我尝
因此,我有一个简单的 Flask API 应用程序,它运行在运行 tornado worker 的 gunicorn 上。 gunicorn 命令行是: gunicorn -w 64 --backlo
我已经使用 Gunicorn + Nginx + Supervisor 部署了一个 Django 1.6 应用程序。一切正常,但我的 Gunicorn error.log 一直在发送错误。该文件很大,
我是一名优秀的程序员,十分优秀!