问题描述
在我的Heroku Django应用中,对于用户帐户注册流程,有一个典型的请求激活帐户,该请求在用户收到带有特殊激活" URL的电子邮件时发生.在应用程序中,此激活应该只发生一次.该URL上的唯一标识符是激活令牌.令牌用于激活"帐户,也用于标识用户(从数据库中检索其用户名).使用此令牌后,将其删除.
In my Heroku Django app, for the user account registration flow, there is a typical request activate account that happens when the user receives an email with a special "activate" URL. In the app, this activation should happen only once. The only identifier on that URL is an activation token. The token is used to "activate" the account, and also to identify the user (retrieve his username from the DB). Once this token is used, it is deleted.
因此,激活必须只发生一次.但是,出于种种奇怪的原因,当请求发送到我的Heroku应用程序时,它会两次触发激活功能.我非常确定这不是应用程序中的编程错误,因为在本地开发中激活不会被调用两次,在暂存环境中也不会被调用(在Heroku上也是如此,几乎与生产设置相同).它只会在生产中发生.
For that reason, activation must happen only once. However, for really odd reasons, when the request is sent to my Heroku app, it triggers the activate function twice. I am quite sure this is not a programming mistake in the app, because on local development the activation is not called twice, and neither on staging environment (which is on Heroku too, almost identical to production settings). It only happens in production.
这是我在heroku logs
中看到的内容: http://pastebin.com/QeuP74fa
Here is what I see in heroku logs
:http://pastebin.com/QeuP74fa
此日志的第一季度很有趣.请注意,在某个时候激活成功,并尝试将用户重定向到下一个正确的页面:GET请求到/iro/dashboard.但是随后发生激活请求,因此您看到的与"NoneType"对象有关的崩溃没有属性...
The first quarter of this log is interesting. Notice that at some point activation succeeded and attempted to redirect the user to the next correct page: GET Request to /iro/dashboard. But then after that the activation request happens, hence the crash that you see related to a "NoneType" object has no attribute...
我的Procfile看起来像这样
My Procfile looks like this
web: newrelic-admin run-program gunicorn --bind=0.0.0.0:$PORT --workers=1 --log-level=debug iroquote.wsgi:application
worker: python manage.py rqworker high default low
当我发现bug时,我正在运行2个Web dynos和1个worker dyno.我试图缩小到1个Web dyno和1个worker,同样的错误.然后完全是0个dyno,然后重新启动了1个Web dyno,仍然是0个worker,相同的错误.
I had 2 web dynos running, and 1 worker dyno, when I found the bug. I have tried to scale down to 1 web dyno and 1 worker, same bug. Then 0 dynos at all, and restarted 1 web dyno, still 0 worker, same bug.
可能与Heroku路由器相关的某事两次调用了dyno,或者可能没有.
Might something related to the Heroku router calling the dyno twice, or might not.
帮助?
推荐答案
安静地,它停止了发生.这很可能是Heroku中的路由问题,影响了我的应用程序.
Silently, it stopped happening. This was likely a routing problem in Heroku that affected my app.
这篇关于Heroku的一个请求产生了两个响应,这些响应使我的应用程序崩溃了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!