在 Heroku 中,如何运行 gunicorn 和导入白噪声?


2020-10-01T03:28:40.496699+00:00 heroku[web.1]: Starting process with command `gunicorn Nstory.wsgi --log-file -`
2020-10-01T03:28:43.803839+00:00 heroku[web.1]: State changed from starting to up
2020-10-01T03:28:43.367859+00:00 app[web.1]: [2020-10-01 03:28:43 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-10-01T03:28:43.368669+00:00 app[web.1]: [2020-10-01 03:28:43 +0000] [4] [INFO] Listening at: http://0.0.0.0:35650 (4)
2020-10-01T03:28:43.368936+00:00 app[web.1]: [2020-10-01 03:28:43 +0000] [4] [INFO] Using worker: sync
2020-10-01T03:28:43.374298+00:00 app[web.1]: [2020-10-01 03:28:43 +0000] [9] [INFO] Booting worker with pid: 9
2020-10-01T03:28:43.382660+00:00 app[web.1]: [2020-10-01 03:28:43 +0000] [10] [INFO] Booting worker with pid: 10
2020-10-01T03:28:44.338145+00:00 app[web.1]: [2020-10-01 12:28:44 +0900] [9] [ERROR] Exception in worker process
2020-10-01T03:28:44.338188+00:00 app[web.1]: Traceback (most recent call last):
2020-10-01T03:28:44.338190+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-10-01T03:28:44.338191+00:00 app[web.1]: worker.init_process()
2020-10-01T03:28:44.338191+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-10-01T03:28:44.338192+00:00 app[web.1]: self.load_wsgi()
2020-10-01T03:28:44.338192+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-10-01T03:28:44.338192+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-10-01T03:28:44.338193+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-10-01T03:28:44.338193+00:00 app[web.1]: self.callable = self.load()
2020-10-01T03:28:44.338194+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-10-01T03:28:44.338194+00:00 app[web.1]: return self.load_wsgiapp()
2020-10-01T03:28:44.338195+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-10-01T03:28:44.338195+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-10-01T03:28:44.338195+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2020-10-01T03:28:44.338196+00:00 app[web.1]: mod = importlib.import_module(module)
2020-10-01T03:28:44.338196+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-10-01T03:28:44.338197+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-10-01T03:28:44.338198+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2020-10-01T03:28:44.338198+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2020-10-01T03:28:44.338199+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2020-10-01T03:28:44.338199+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2020-10-01T03:28:44.338199+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2020-10-01T03:28:44.338200+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-10-01T03:28:44.338200+00:00 app[web.1]: File "/app/Nstory/wsgi.py", line 19, in <module>
2020-10-01T03:28:44.338200+00:00 app[web.1]: from whitenoise.django import DjangoWhiteNoise
2020-10-01T03:28:44.338201+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/whitenoise/django.py", line 1, in <module>
2020-10-01T03:28:44.338201+00:00 app[web.1]: raise ImportError(
2020-10-01T03:28:44.338202+00:00 app[web.1]: ImportError:
2020-10-01T03:28:44.338202+00:00 app[web.1]:
2020-10-01T03:28:44.338203+00:00 app[web.1]: Your WhiteNoise configuration is incompatible with WhiteNoise v4.0
2020-10-01T03:28:44.338203+00:00 app[web.1]: This can be fixed by following the upgrade instructions at:
2020-10-01T03:28:44.338203+00:00 app[web.1]: http://whitenoise.evans.io/en/stable/changelog.html#v4-0
2020-10-01T03:28:44.338204+00:00 app[web.1]:
2020-10-01T03:28:44.338204+00:00 app[web.1]:
2020-10-01T03:28:44.338364+00:00 app[web.1]: [2020-10-01 12:28:44 +0900] [9] [INFO] Worker exiting (pid: 9)
2020-10-01T03:28:44.357550+00:00 app[web.1]: [2020-10-01 12:28:44 +0900] [10] [ERROR] Exception in worker process
2020-10-01T03:28:44.357552+00:00 app[web.1]: Traceback (most recent call last):
2020-10-01T03:28:44.357553+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-10-01T03:28:44.357554+00:00 app[web.1]: worker.init_process()
2020-10-01T03:28:44.357555+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-10-01T03:28:44.357555+00:00 app[web.1]: self.load_wsgi()
2020-10-01T03:28:44.357556+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-10-01T03:28:44.357556+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-10-01T03:28:44.357559+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-10-01T03:28:44.357560+00:00 app[web.1]: self.callable = self.load()
2020-10-01T03:28:44.357560+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-10-01T03:28:44.357561+00:00 app[web.1]: return self.load_wsgiapp()
2020-10-01T03:28:44.357561+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-10-01T03:28:44.357561+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-10-01T03:28:44.357567+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2020-10-01T03:28:44.357568+00:00 app[web.1]: mod = importlib.import_module(module)
2020-10-01T03:28:44.357568+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-10-01T03:28:44.357569+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-10-01T03:28:44.357569+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2020-10-01T03:28:44.357569+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2020-10-01T03:28:44.357570+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2020-10-01T03:28:44.357585+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2020-10-01T03:28:44.357586+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2020-10-01T03:28:44.357586+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-10-01T03:28:44.357587+00:00 app[web.1]: File "/app/Nstory/wsgi.py", line 19, in <module>
2020-10-01T03:28:44.357587+00:00 app[web.1]: from whitenoise.django import DjangoWhiteNoise
2020-10-01T03:28:44.357588+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/whitenoise/django.py", line 1, in <module>
2020-10-01T03:28:44.357588+00:00 app[web.1]: raise ImportError(
2020-10-01T03:28:44.357588+00:00 app[web.1]: ImportError:
2020-10-01T03:28:44.357589+00:00 app[web.1]:
2020-10-01T03:28:44.357589+00:00 app[web.1]: Your WhiteNoise configuration is incompatible with WhiteNoise v4.0
2020-10-01T03:28:44.357590+00:00 app[web.1]: This can be fixed by following the upgrade instructions at:
2020-10-01T03:28:44.357590+00:00 app[web.1]: http://whitenoise.evans.io/en/stable/changelog.html#v4-0
2020-10-01T03:28:44.357590+00:00 app[web.1]:
2020-10-01T03:28:44.357591+00:00 app[web.1]:
2020-10-01T03:28:44.357945+00:00 app[web.1]: [2020-10-01 12:28:44 +0900] [10] [INFO] Worker exiting (pid: 10)
2020-10-01T03:28:44.641942+00:00 app[web.1]: [2020-10-01 03:28:44 +0000] [4] [INFO] Shutting down: Master
2020-10-01T03:28:44.642070+00:00 app[web.1]: [2020-10-01 03:28:44 +0000] [4] [INFO] Reason: Worker failed to boot.

我试过运行gunicorn和进口whiteoise。类似于导入from whitenoise.django import DjangoWhiteNoise和添加MIDDLEWARE'whitenoise.middleware.WhiteNoiseMiddleware',,并类似于STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'定义静态文件_存储但没用。。。

我看过heroku django教程和mozila教程https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Deploymenthttps://devcenter.heroku.com/articles/django-app-configuration所以我已经尝试更改关于静态文件的配置,并导入whiteoise。但这无济于事。

是什么导致导入错误?如何部署我的网站?

如下所示,您的配置与WhiteNoise v4.0不兼容。(也许教程没有更新(。在这里,您可以检查新版本中的更改。

2020-10-01T03:28:44.338202+00:00 app[web.1]: ImportError:
2020-10-01T03:28:44.338202+00:00 app[web.1]:
2020-10-01T03:28:44.338203+00:00 app[web.1]: Your WhiteNoise configuration is incompatible with WhiteNoise v4.0
2020-10-01T03:28:44.338203+00:00 app[web.1]: This can be fixed by following the upgrade instructions at:
2020-10-01T03:28:44.338203+00:00 app[web.1]: http://whitenoise.evans.io/en/stable/changelog.html#v4-0

尝试使用

from whitenoise import WhiteNoise

代替

from whitenoise.django import DjangoWhiteNoise

相关内容

  • 没有找到相关文章

最新更新