【问题标题】:Heroku worker suddenly crashes, logs don't show any of my scripts. What happened?Heroku 工作人员突然崩溃,日志没有显示我的任何脚本。发生了什么?
【发布时间】:2020-02-06 21:30:59
【问题描述】:

我在 heroku 上托管了一个烧瓶、gunicorn、postgresql 项目,但它突然失败了。我可以访问日志,但是没有我写的脚本,所以我很困惑。我没有在“工作”和“不工作”之间添加任何内容,所以我不知道从哪里开始。

日志可以在这个pastebin中找到。 最后一部分是:

2020-02-06T21:09:02.748093+00:00 app[web.1]: from werkzeug.contrib.cache import FileSystemCache
2020-02-06T21:09:02.748100+00:00 app[web.1]: ModuleNotFoundError: No module named 'werkzeug.contrib'
2020-02-06T21:09:02.748789+00:00 app[web.1]: [2020-02-06 21:09:02 +0000] [10] [INFO] Worker exiting (pid: 10)

我尝试将 werkzeug 添加到 requirements.txt,但这没有帮助。无论如何这都会很奇怪,因为它在没有改变需求的情况下工作正常。

如果您能帮助我减少 requirements.txt,我们将不胜感激。

原始需求.txt:

cs50
Flask
Flask-Session
requests
gunicorn
psycopg2-binary
openpyxl

新的,工作的:

astroid==2.3.3
attrs==19.3.0
Authlib==0.13
autopep8==1.5
awscli==1.17.9
backports.shutil-get-terminal-size==1.0.0
backports.shutil-which==3.5.2
beautifulsoup4==4.8.2
botocore==1.14.9
bs4==0.0.1
cairocffi==1.1.0
CairoSVG==2.4.2
certifi==2019.11.28
cffi==1.13.2
chardet==3.0.4
check50==3.0.10
Click==7.0
colorama==0.4.1
compare50==1.1.2
cryptography==2.8
cs50==5.0.3
cssselect2==0.2.2
cycler==0.10.0
defusedxml==0.6.0
docutils==0.15.2
EditorConfig==0.12.2
et-xmlfile==1.0.1
Flask==1.1.1
Flask-Session==0.3.1
help50==3.0.0
html5lib==1.0.1
icdiff==1.9.1
idna==2.8
ikp3db==1.4.1
intervaltree==2.1.0
isort==4.3.21
itsdangerous==1.1.0
jdcal==1.4.1
jellyfish==0.7.2
Jinja2==2.11.1
jmespath==0.9.4
jsbeautifier==1.10.3
kiwisolver==1.1.0
lazy-object-proxy==1.4.3
lib50==2.0.7
logger==1.4
MarkupSafe==1.1.1
matplotlib==3.1.3
mccabe==0.6.1
natsort==7.0.1
nltk==3.4.5
numpy==1.18.1
oauthlib==3.1.0
openpyxl==3.0.3
pandas==1.0.0
pexpect==4.8.0
Pillow==7.0.0
plotly==4.5.0
psycopg2-binary==2.8.4
ptyprocess==0.6.0
pyasn1==0.4.8
pycodestyle==2.5.0
pycparser==2.19
Pygments==2.5.2
pylint==2.4.4
pylint-django==2.0.13
pylint-flask==0.6
pylint-plugin-utils==0.6
pyparsing==2.4.6
PyPDF2==1.26.0
Pyphen==0.9.5
python-dateutil==2.8.1
python-magic==0.4.15
pytz==2019.3
PyYAML==5.2
render50==3.1.3
requests==2.22.0
requests-oauthlib==1.3.0
retrying==1.3.3
rsa==3.4.2
s3cmd==2.0.2
s3transfer==0.3.2
six==1.14.0
sortedcontainers==2.1.0
soupsieve==1.9.5
SQLAlchemy==1.3.13
sqlparse==0.3.0
style50==2.7.4
submit50==3.0.2
termcolor==1.1.0
tinycss2==1.0.2
tqdm==4.42.1
twython==3.7.0
typed-ast==1.4.1
urllib3==1.25.8
virtualenv==16.7.9
WeasyPrint==49
webencodings==0.5.1
Werkzeug==0.16.1
wrapt==1.11.2
gunicorn

【问题讨论】:

  • 请提供requiremets.txt
  • 我可以恢复到工作版本。我更改了 github 中的 readme.md。这就是我在比较中所能看到的。
  • 但是,请提供requirements.txt 以确保完整性。
  • 感谢您指出我的要求。它又回到了可用状态。我在我的 IDE 中做了冻结的事情,现在我的要求很丑,但是可​​以工作。必须弄清楚差异在哪里。
  • 我强烈建议使用Poetry 进行包管理。

标签: heroku flask logging


【解决方案1】:

Werkzeug 昨天发布了一个新版本:

Release history

显然werkzeug.contrib 已移至单独的模块

建议试试

./env/bin/pip install werkzeug==0.16.0

【讨论】:

  • 哈!我想这就是原因。很高兴知道这不是我的直接代码。或者它是,但只是因为我没有指定版本。非常感谢,马丁。
  • 是的。这个错误花了我大约六个小时的时间来试图弄清楚我做了哪些改变,以至于严重地搞砸了狗。两周前我为此浪费了 12 个小时 ::Cannot run Cypress on Ubuntu 18.04 现在这会成为一种趋势吗?
【解决方案2】:

这是另一种可能适合您的解决方案。

因为Werkzeug 1.0.0 已从werkzeug.contrib 中删除了已弃用的代码。

我在尝试在werkzeug==1.0.0 中使用Proxyfix 时遇到了同样的问题

降级到werkzeug==0.16.0 后,我收到以下警告:

DeprecationWarning: 'werkzeug.contrib.fixers.ProxyFix' has moved to 'werkzeug.middleware.proxy_fix.ProxyFix'.
This import is deprecated as of version 0.15 and will be removed in 1.0.
DeprecationWarning: 'werkzeug.contrib.cache' is deprecated as of version 0.15 and will be removed in version 1.0. It has moved to pallets.
from werkzeug.contrib.cache import FileSystemCache

解决问题:

pip install werkzeug==1.0.0

对于ProxyFix

from werkzeug.middleware.proxy_fix import ProxyFix

对于FileSystemCache,您必须安装托盘:

pip install -U cachelib
from cachelib.file import FileSystemCache

我希望这有助于解决您的问题?

【讨论】:

  • 谢谢,如果我需要使用更新版本的 werkzeug,这将是一个解决方案。到目前为止,我一直在使用旧版本,因为我不需要新版本的任何特别之处。谁知道这是否适用于未来。现在我知道如何处理这种情况了。
猜你喜欢
  • 2012-04-24
  • 2020-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-09
  • 1970-01-01
  • 2021-08-11
  • 2010-11-09
相关资源
最近更新 更多