我有一个在本地运行良好的django项目,还有一个为django应用程序正确创建Docker映像的Dockerfile。该映像可以在Heroku上很好地部署,并可以正确打开登录到管理页面。如果我输入了错误的凭据,则应用程序会迅速引发无效的凭据错误。但是,如果我输入正确的凭据,则该应用程序将继续运行,直到Heroku超时(无法更改的30秒)到期为止。
我正在使用Postgres插件,并且由于上面提到的凭据错误(当我尝试使用不正确的用户登录时),我认为它的配置正确(以及settings.py)。
请求超时时在日志中引发的错误如下:
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line
618, in send
2018-12-20T17:20:56.027703+00:00 app[web.1]: r =
adapter.send(request, **kwargs)
2018-12-20T17:20:56.027704+00:00 app[web.1]: File
"/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 508,
in send
2018-12-20T17:20:56.027705+00:00 app[web.1]: raise ConnectionError(e,
request=request)
2018-12-20T17:20:56.027707+00:00 app[web.1]:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.5.0.1',
port=8000): Max retries exceeded with url: /authentication/login/ (Caused
by NewConnectionError('<urllib3.connection.HTTPConnection object at
0x7f0cdf24e5c0>: Failed to establish a new connection: [Errno 110]
Operation timed out'))
2018-12-20T17:20:56.333701+00:00 app[web.1]: [20/Dec/2018 17:20:56] "POST
/admin/login/?next=/admin/ HTTP/1.1" 500 281813
Disconnected from log stream. There may be events happening that you do
not see here! Attempting to reconnect...
2018-12-20T17:20:56.027696+00:00 app[web.1]: File
"/usr/local/lib/python3.7/site-packages/requests/api.py", line 58, in
request
2018-12-20T17:20:56.027697+00:00 app[web.1]: return
session.request(method=method, url=url, **kwargs)
2018-12-20T17:20:56.027699+00:00 app[web.1]: File
"/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 508,
in request
2018-12-20T17:20:56.027700+00:00 app[web.1]: resp = self.send(prep,
**send_kwargs)
2018-12-20T17:20:56.027701+00:00 app[web.1]: File
"/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 618,
in send
2018-12-20T17:20:56.027703+00:00 app[web.1]: r =
adapter.send(request, **kwargs)
2018-12-20T17:20:56.027704+00:00 app[web.1]: File
"/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 508,
in send
2018-12-20T17:20:56.027705+00:00 app[web.1]: raise ConnectionError(e,
request=request)
2018-12-20T17:20:56.027707+00:00 app[web.1]:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.5.0.1',
port=8000): Max retries exceeded with url: /authentication/login/ (Caused
by NewConnectionError('<urllib3.connection.HTTPConnection object at
0x7f0cdf24e5c0>: Failed to establish a new connection: [Errno 110]
Operation timed out'))
2018-12-20T17:20:56.333701+00:00 app[web.1]: [20/Dec/2018 17:20:56] "POST
/admin/login/?next=/admin/ HTTP/1.1" 500 281813
您可以看到它完整here
我在Dockerfile上的这一行在Heroku中启动该过程:
CMD [“ sh”,“-c”,“ python3 manage.py runserver 0.0.0.0:$PORT”]
我也尝试过使用gunicorn,但仍然遇到相同的错误。
我想我缺少了什么,但我不知道什么。