[英]Flask Nginx uWSGI 504 Gateway Timeout Error
我拼命想弄清楚为什么我不能用 uWSGI nginx 和 Ubuntu 服务器部署我的烧瓶应用程序的问题。
这是我在nginx 错误日志中的错误:
2019/05/12 09:00:19 [error] 10154#10154: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 24.27.57.18, server: itinareport.tk, request: "POST /login HTTP/1.1", upstream: "uwsgi://unix:/home/pinchrep2/itinarep/itinarep.sock", host: "www.itinareport.tk", referrer: "http://www.itinareport.tk/login"
在使用 Flask uWSGI 和 nginx 设置好所有内容后,我可以输入我的域名,然后它会将我带到我的网页(登录页面)。 尝试登录时页面暂停一段时间,然后我收到504 网关超时
请建议我应该怎么做。 这是我第一次部署应用程序,我花了大约一周的时间尝试不同的配置。 我应该让您知道我的 Flask 应用程序通过 ssh 隧道连接到另一个服务器的数据库。 不确定这是否也会导致此问题。 如果可能,请提供帮助或为我指明正确的方向。
这是我的服务器块配置文件
server{
listen 80;
server_name itinareport.tk www.itinareport.tk;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/pinchrep2/itinarep/itinarep.sock;
}
这是我的服务文件:
[Unit]
Description=uWSGI instance to serve itinarep
After=network.target
[Service]
User=pinchrep2
Group=www-data
WorkingDirectory=/home/pinchrep2/itinarep
Environment="PATH=/home/pinchrep2/itinarep/it_venv/bin"
ExecStart=/home/pinchrep2/itinarep/it_venv/bin/uwsgi --ini itinarep.ini
[Install]
WantedBy=multi-user.target
这是我的ini文件
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = itinarep.sock
chmod-socket = 660
vacuum = true
die-on-term=true
有时,在使用 Keras 等库部署 Flask 应用程序时,他们在 uWSGI 中遇到线程问题。
您可以在 myproject.ini 中更改一些内容以使其工作:
master = false <-------- this
processes = 1 <--------- and this
cheaper = 0
到您的 myproject.inilazy-apps = true
添加到您的 myproject.ini所以现在你的 myproject.ini 文件可能看起来像:
[uwsgi]
module = wsgi:app
master = false <-------- this
processes = 1 <--------- and this
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
cheaper = 0 <----------- also this, if option 1 is not enough or doesn't work
lazy-apps = true <------ in some case, this might help
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.