supervisor 部署问题,单独用 gunicorn 启动是可以正常使用的,加上 supervisor,一跳转就会 500,求帮忙

2017-06-05 11:11:00 +08:00
 toarya
部署完 gunicorn+ngnix+supervisor 后可以进入 /user/的登录界面,但是输入表单后,点登录跳转,就会直接
Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

不用 supervisor,直接在项目目录用 gunicorn 启动就没问题。

gunicrorn 日志如下,但不知道怎么能看到更详细点的日志...
127.0.0.1 - - [05/Jun/2017:09:41:36 +0800] "GET / HTTP/1.0" 302 219 "-"
127.0.0.1 - - [05/Jun/2017:09:41:36 +0800] "GET /user/ HTTP/1.0" 200 3902 "-"
127.0.0.1 - - [05/Jun/2017:09:41:36 +0800] "GET /static/images/icons.png HTTP/1.0" 404 233 "http://XXX.XX.XXX.238/static/css/login_style.css"
127.0.0.1 - - [05/Jun/2017:09:41:40 +0800] "POST /user/login HTTP/1.0" 500 291 "http://XXX.XX.XXX.238/user/"


supervisor 配置如下
[program:tweet-demo]
command=/usr/local/bin/gunicorn wsgi --worker-class=gevent --bind 0.0.0.0:8001 --pid /tmp/tweet-demo.pid
directory=/home/ubuntu/demo/tweet-demo

求解救...
4078 次点击
所在节点    Python
9 条回复
konia
2017-06-05 12:24:58 +08:00
不用 nginx 直接访问 8001,也会这样吗?
toarya
2017-06-05 12:58:33 +08:00
@konia 是的,奇怪的是注册功能倒是没问题....
parametrix
2017-06-05 13:12:46 +08:00
楼主确定 gunicorn 是正常运行的么,我印象中旧版本的 supervisor 运行 python 程序有 Bug 来着。
parametrix
2017-06-05 13:19:29 +08:00
你看下是不是这个问题:

···
#!/usr/bin/env bash

cd /var/www/monmar

export $(cat .env) && exec .venv/bin/gunicorn config.wsgi -c deploy/gunicorn.conf.py
···

Please pay attention that we're not calling .venv/bin/gunicorn directly, but wrapping it with exec. If you don't do that, your Gunicorn program won't be supervisored, and you won't be able to stop and restart it properly.


Ref: https://samoylov.eu/2016/08/31/deploying-django-with-gunicorn-and-supervisor/
robinlovemaggie
2017-06-05 13:22:26 +08:00
论日志的重要性
toarya
2017-06-05 14:34:50 +08:00
@parametrix 谢谢!好像确实是这个问题,之前输出的日志是空的,这样跑了一下终于看到具体的异常了。
loveminds
2017-06-05 15:41:26 +08:00
@parametrix 为啥不直接用 systemd 启动
parametrix
2017-06-05 15:45:28 +08:00
@loveminds 说得好,我一般也是直接用 systemd 的 :)
loveminds
2017-06-06 04:47:31 +08:00
@parametrix 我是超讨厌超级猥琐这种画蛇添足的东西,在它可以作为正式的 init 之前,多出的层级意味着损失效率和徒增故障点,systemd 的日志已经相当完善了,至于有些人要的 web 控制台,也有相应组件

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/366004

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX