Internal Server Error 各位哥哥姐姐帮帮看下
运行环境 服务器操作系统:Ubuntu Server 16.04.1 LTS 64 位 项目开发部署方案:Falsk + nginx + uwsgi 在 python3.6 虚拟环境下运行的
本地测试可以访问,部署上云服务器之后出现了这种问题。 然后查看了 logs 错误输出日志,发现报错如下: --- no python application found, check your startup logs for errors --- [pid: 4757|app: -1|req: -1/1] 139.214.254.164 () {40 vars in 841 bytes} [Wed Jun 13 22:42:12 2018] GET / => generated 0 bytes in 3 msecs (HTTP/1.1 500) 2 headers in 0 bytes (0 switches on core 0) Wed Jun 13 22:42:12 2018 - uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during GET / (139.214.254.164) --- no python application found, check your startup logs for errors --- [pid: 4756|app: -1|req: -1/2] 139.214.254.164 () {40 vars in 841 bytes} [Wed Jun 13 22:42:12 2018] GET / => generated 0 bytes in 32 msecs (HTTP/1.1 500) 2 headers in 0 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 4757|app: -1|req: -1/3] 139.214.254.164 () {38 vars in 845 bytes} [Wed Jun 13 22:42:12 2018] GET /favicon.ico => generated 21 bytes in 27 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) spawned uWSGI worker 4 (pid: 4759, cores: 1) spawned WSGI worker 5 (pid: 4760, cores: 1
然后我多次在网上查询,大多说是 uwsgi 配置问题,我没有检查出来,所以这里也把配置贴出来罢
[uwsgi]
chdir = /srv/webtest
module = demo
home = /root/.virtualenvs/benmoom-env-py3
master = true
processes = 10
socket = /srv/webtest/benmoom.sock
wsgi-file = /srv/webtest/demo.py
callable = app
chmod-socket = 666
vacuum = true
1
bufu OP 没人?自己顶一下。
|
2
bufu OP 找到错误原因,在我的主 app 文件 demo.py 中这样写的:
if __name__ == '__main__': app = create_app() app.run() 乍一看没什么问题,这样写当然在本地运行也没啥问题。但是在服务上就会报错 python application found, check your startup logs for errors。这是因为在项目上线后,通过 uwsgi 服务器,给项目做一些非静态的处理,部分配置 wsgi-file = /srv/webtest/demo.py callable = app 如果,uwsgi 没有找到 demo.py 中的 app,项目就无法得到代理。项目无法正常访问,在浏览器上提示内部服务器错误就很正常了。uwsgi 启动没有报错,是因为这并不是 uwsgi 配置的错。 修改如下: app = create_app() if __name__ == '__main__': app.run() |
3
h19981126g 2018-08-15 20:27:23 +08:00
@bufu 我想问下我是 webpy 也是 nginx+uwsgi 出现了 ” Internal Server Error “要怎么改?
|