我在Ubuntu上部署了我的Python Flask应用程序,我正在使用Gunicorn和nginx .

我仔细地阅读了本教程

Digital Ocean tutorial on Flask deplyment using Gunicorn and Nginx

但有时我的应用程序停止并生成500错误或502错误,直到我通过执行systemctl重新启动应用程序重新启动.sock文件

当我检查错误日志时,我明白了

2016/10/20 23:37:18 [crit] 12366#12366: *47260 connect() to   unix:/home/myusername/myapp/myapp.sock failed (2: No such file or directory) while connecting to upstream, client: 78.206.179.140, server: 000.111.222.333, request: "GET /goods HTTP/1.1", upstream: "http://unix:/home/myusername/myapp/myapp.sock:/live-calls", host: "000.111.222.333", referrer: "http://000.111.222.333/goods"

有时我会在读取上游错误时得到过早关闭的连接 .