【发布时间】:2019-02-11 12:58:36
【问题描述】:
我已经使用 tutorial 部署了我的应用程序
我使用 nginx+gunicorn(我也使用 systemd)
现在在我的dev server 上一切正常
但是在生产中它失败了
Internal Server Error 当我尝试下载文件时
如何以及在哪里可以找到 gunicorn 日志?(我使用 ubuntu)
另外,这是一段会导致错误以防万一的代码:
def download_xlsx(request):
user = request.user
file_name = request.GET['file_name']
file_path='main_app/static/xlsx/' + str(user.id) + '/' + file_name
disposition= 'attachment; filename="' +smart_str(file_name) + '"'
disposition=disposition.encode('utf-8')
if os.path.exists(file_path):
with open(file_path, 'rb') as fh:
response = HttpResponse(fh.read(), content_type="application/vnd.ms-excel")
response['Content-Disposition'] = disposition
return response
return projects.to_utf8_json_response('not found')
UPD:我尝试运行sudo journalctl -u gunicorn
但是我得到了一个从 2 个月前开始的大文件,所以我无法查看最新的日志,因为它的大小
【问题讨论】:
标签: django python-3.x gunicorn