Heroku Django crashed: at=error code=H10 desc=“App crashed”



我正在尝试在Heroku上部署我的Django项目。但每次我都有同样的错误。Heroku重启对我不起作用。我清除了buildpack并添加了python buildpack。这对我不起作用。我也尝试过不同的主机,比如ALLOWED_HOSTS = ['*', '127.0.0.1', 'dailynotes.herokuapp.com']。在配置文件中,我尝试了不同的方式,如web: gunicorn ToDoApps.wsgi: --log-file -

web: gunicorn ToDoApps.wsgi:application --log-file - --log-level debug
python manage.py collectstatic --noinput
manage.py migrate

这个不适合我。

坠毁文件

2021-08-18T09:37:39.832259+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dailynotes.herokuapp.com request_id=81cc172e-247e-4aa9-8b39-fb9440cd67d2 fwd="103.14.72.227" dyno= connect= service= status=503 bytes= protocol=https
2021-08-18T09:37:40.734680+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dailynotes.herokuapp.com request_id=8d2598b4-0521-4519-892a-467d2a2642ca fwd="103.14.72.227" dyno= connect= service= status=503 bytes= protocol=https

日志——尾巴

2021-08-18T09:21:46.641887+00:00 app[web.1]: preload_app: False
2021-08-18T09:21:46.641888+00:00 app[web.1]: sendfile: None
2021-08-18T09:21:46.641888+00:00 app[web.1]: reuse_port: False
2021-08-18T09:21:46.641888+00:00 app[web.1]: chdir: /app
2021-08-18T09:21:46.641889+00:00 app[web.1]: daemon: False
2021-08-18T09:21:46.641889+00:00 app[web.1]: raw_env: []
2021-08-18T09:21:46.641889+00:00 app[web.1]: pidfile: None
2021-08-18T09:21:46.641889+00:00 app[web.1]: worker_tmp_dir: None
2021-08-18T09:21:46.641890+00:00 app[web.1]: user: 9071
2021-08-18T09:21:46.641890+00:00 app[web.1]: group: 9071
2021-08-18T09:21:46.641890+00:00 app[web.1]: umask: 0
2021-08-18T09:21:46.641891+00:00 app[web.1]: initgroups: False
2021-08-18T09:21:46.641891+00:00 app[web.1]: tmp_upload_dir: None
2021-08-18T09:21:46.641909+00:00 app[web.1]: secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
2021-08-18T09:21:46.641909+00:00 app[web.1]: forwarded_allow_ips: ['*']
2021-08-18T09:21:46.641909+00:00 app[web.1]: accesslog: -
2021-08-18T09:21:46.641910+00:00 app[web.1]: disable_redirect_access_to_syslog: False
2021-08-18T09:21:46.641916+00:00 app[web.1]: access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
2021-08-18T09:21:46.641917+00:00 app[web.1]: errorlog: -
2021-08-18T09:21:46.641917+00:00 app[web.1]: loglevel: debug
2021-08-18T09:21:46.641918+00:00 app[web.1]: capture_output: False
2021-08-18T09:21:46.641918+00:00 app[web.1]: logger_class: gunicorn.glogging.Logger
2021-08-18T09:21:46.641918+00:00 app[web.1]: logconfig: None
2021-08-18T09:21:46.641919+00:00 app[web.1]: logconfig_dict: {}
2021-08-18T09:21:46.641919+00:00 app[web.1]: syslog_addr: udp://localhost:514
2021-08-18T09:21:46.641919+00:00 app[web.1]: syslog: False
2021-08-18T09:21:46.641920+00:00 app[web.1]: syslog_prefix: None
2021-08-18T09:21:46.641920+00:00 app[web.1]: syslog_facility: user
2021-08-18T09:21:46.641921+00:00 app[web.1]: enable_stdio_inheritance: False
2021-08-18T09:21:46.641921+00:00 app[web.1]: statsd_host: None
2021-08-18T09:21:46.641921+00:00 app[web.1]: dogstatsd_tags:
2021-08-18T09:21:46.641922+00:00 app[web.1]: statsd_prefix:
2021-08-18T09:21:46.641922+00:00 app[web.1]: proc_name: None
2021-08-18T09:21:46.641923+00:00 app[web.1]: default_proc_name: ToDoApps.wsgi:application
2021-08-18T09:21:46.641923+00:00 app[web.1]: pythonpath: None
2021-08-18T09:21:46.641923+00:00 app[web.1]: paste: None
2021-08-18T09:21:46.642453+00:00 app[web.1]: on_starting: <function OnStarting.on_starting at 0x7fef7fcbb9d0>
2021-08-18T09:21:46.642454+00:00 app[web.1]: on_reload: <function OnReload.on_reload at 0x7fef7fcbbaf0>
2021-08-18T09:21:46.642454+00:00 app[web.1]: when_ready: <function WhenReady.when_ready at 0x7fef7fcbbc10>
2021-08-18T09:21:46.642455+00:00 app[web.1]: pre_fork: <function Prefork.pre_fork at 0x7fef7fcbbd30>
2021-08-18T09:21:46.642455+00:00 app[web.1]: post_fork: <function Postfork.post_fork at 0x7fef7fcbbe50>
2021-08-18T09:21:46.642455+00:00 app[web.1]: post_worker_init: <function PostWorkerInit.post_worker_init at 0x7fef7fcbbf70>
2021-08-18T09:21:46.642456+00:00 app[web.1]: worker_int: <function WorkerInt.worker_int at 0x7fef7fccc0d0>
2021-08-18T09:21:46.642456+00:00 app[web.1]: worker_abort: <function WorkerAbort.worker_abort at 0x7fef7fccc1f0>
2021-08-18T09:21:46.642456+00:00 app[web.1]: pre_exec: <function PreExec.pre_exec at 0x7fef7fccc310>
2021-08-18T09:21:46.642457+00:00 app[web.1]: pre_request: <function PreRequest.pre_request at 0x7fef7fccc430>
2021-08-18T09:21:46.642457+00:00 app[web.1]: post_request: <function PostRequest.post_request at 0x7fef7fccc4c0>
2021-08-18T09:21:46.642458+00:00 app[web.1]: child_exit: <function ChildExit.child_exit at 0x7fef7fccc5e0>
2021-08-18T09:21:46.642458+00:00 app[web.1]: worker_exit: <function WorkerExit.worker_exit at 0x7fef7fccc700>
2021-08-18T09:21:46.642458+00:00 app[web.1]: nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7fef7fccc820>
2021-08-18T09:21:46.642459+00:00 app[web.1]: on_exit: <function OnExit.on_exit at 0x7fef7fccc940>
2021-08-18T09:21:46.642459+00:00 app[web.1]: proxy_protocol: False
2021-08-18T09:21:46.642459+00:00 app[web.1]: proxy_allow_ips: ['127.0.0.1']
2021-08-18T09:21:46.642460+00:00 app[web.1]: keyfile: None
2021-08-18T09:21:46.642460+00:00 app[web.1]: certfile: None
2021-08-18T09:21:46.642460+00:00 app[web.1]: ssl_version: 2
2021-08-18T09:21:46.642461+00:00 app[web.1]: cert_reqs: 0
2021-08-18T09:21:46.642461+00:00 app[web.1]: ca_certs: None
2021-08-18T09:21:46.642461+00:00 app[web.1]: suppress_ragged_eofs: True
2021-08-18T09:21:46.642462+00:00 app[web.1]: do_handshake_on_connect: False
2021-08-18T09:21:46.642462+00:00 app[web.1]: ciphers: None
2021-08-18T09:21:46.642462+00:00 app[web.1]: raw_paste_global_conf: []
2021-08-18T09:21:46.642463+00:00 app[web.1]: strip_header_spaces: False
2021-08-18T09:21:46.643622+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-08-18T09:21:46.644633+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [DEBUG] Arbiter booted
2021-08-18T09:21:46.644821+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Listening at: http://0.0.0.0:44920 (4)
2021-08-18T09:21:46.645051+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Using worker: sync
2021-08-18T09:21:46.652069+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [7] [INFO] Booting worker with pid: 7
2021-08-18T09:21:46.662712+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [7] [ERROR] Exception in worker process
2021-08-18T09:21:46.662715+00:00 app[web.1]: Traceback (most recent call last):
2021-08-18T09:21:46.662715+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-08-18T09:21:46.662716+00:00 app[web.1]: worker.init_process()
2021-08-18T09:21:46.662716+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-08-18T09:21:46.662717+00:00 app[web.1]: self.load_wsgi()
2021-08-18T09:21:46.662717+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-08-18T09:21:46.662718+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-08-18T09:21:46.662718+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-08-18T09:21:46.662718+00:00 app[web.1]: self.callable = self.load()
2021-08-18T09:21:46.662719+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-08-18T09:21:46.662719+00:00 app[web.1]: return self.load_wsgiapp()
2021-08-18T09:21:46.662719+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-08-18T09:21:46.662720+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-08-18T09:21:46.662720+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2021-08-18T09:21:46.662720+00:00 app[web.1]: mod = importlib.import_module(module)
2021-08-18T09:21:46.662721+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2021-08-18T09:21:46.662721+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-08-18T09:21:46.662722+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2021-08-18T09:21:46.662722+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2021-08-18T09:21:46.662723+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2021-08-18T09:21:46.662723+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2021-08-18T09:21:46.662723+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2021-08-18T09:21:46.662724+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2021-08-18T09:21:46.662724+00:00 app[web.1]: File "/app/ToDoApps/wsgi.py", line 12, in <module>
2021-08-18T09:21:46.662725+00:00 app[web.1]: from django.core.wsgi import get_wsgi_application
2021-08-18T09:21:46.662725+00:00 app[web.1]: ModuleNotFoundError: No module named 'django'
2021-08-18T09:21:46.662924+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-08-18T09:21:46.707594+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Shutting down: Master
2021-08-18T09:21:46.707848+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-08-18T09:21:46.836081+00:00 heroku[web.1]: Process exited with status 3
2021-08-18T09:21:47.118125+00:00 heroku[web.1]: State changed from starting to crashed
2021-08-18T09:21:46.641887+00:00 app[web.1]: preload_app: False
2021-08-18T09:21:46.641888+00:00 app[web.1]: sendfile: None
2021-08-18T09:21:46.641888+00:00 app[web.1]: reuse_port: False
2021-08-18T09:21:46.641888+00:00 app[web.1]: chdir: /app
2021-08-18T09:21:46.641889+00:00 app[web.1]: daemon: False
2021-08-18T09:21:46.641889+00:00 app[web.1]: raw_env: []
2021-08-18T09:21:46.641889+00:00 app[web.1]: pidfile: None
2021-08-18T09:21:46.641889+00:00 app[web.1]: worker_tmp_dir: None
2021-08-18T09:21:46.641890+00:00 app[web.1]: user: 9071
2021-08-18T09:21:46.641890+00:00 app[web.1]: group: 9071
2021-08-18T09:21:46.641890+00:00 app[web.1]: umask: 0
2021-08-18T09:21:46.641891+00:00 app[web.1]: initgroups: False
2021-08-18T09:21:46.641891+00:00 app[web.1]: tmp_upload_dir: None
2021-08-18T09:21:46.641909+00:00 app[web.1]: secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
2021-08-18T09:21:46.641909+00:00 app[web.1]: forwarded_allow_ips: ['*']
2021-08-18T09:21:46.641909+00:00 app[web.1]: accesslog: -
2021-08-18T09:21:46.641910+00:00 app[web.1]: disable_redirect_access_to_syslog: False
2021-08-18T09:21:46.641916+00:00 app[web.1]: access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
2021-08-18T09:21:46.641917+00:00 app[web.1]: errorlog: -
2021-08-18T09:21:46.641917+00:00 app[web.1]: loglevel: debug
2021-08-18T09:21:46.641918+00:00 app[web.1]: capture_output: False
2021-08-18T09:21:46.641918+00:00 app[web.1]: logger_class: gunicorn.glogging.Logger
2021-08-18T09:21:46.641918+00:00 app[web.1]: logconfig: None
2021-08-18T09:21:46.641919+00:00 app[web.1]: logconfig_dict: {}
2021-08-18T09:21:46.641919+00:00 app[web.1]: syslog_addr: udp://localhost:514
2021-08-18T09:21:46.641919+00:00 app[web.1]: syslog: False
2021-08-18T09:21:46.641920+00:00 app[web.1]: syslog_prefix: None
2021-08-18T09:21:46.641920+00:00 app[web.1]: syslog_facility: user
2021-08-18T09:21:46.641921+00:00 app[web.1]: enable_stdio_inheritance: False
2021-08-18T09:21:46.641921+00:00 app[web.1]: statsd_host: None
2021-08-18T09:21:46.641921+00:00 app[web.1]: dogstatsd_tags:
2021-08-18T09:21:46.641922+00:00 app[web.1]: statsd_prefix:
2021-08-18T09:21:46.641922+00:00 app[web.1]: proc_name: None
2021-08-18T09:21:46.641923+00:00 app[web.1]: default_proc_name: ToDoApps.wsgi:application
2021-08-18T09:21:46.641923+00:00 app[web.1]: pythonpath: None
2021-08-18T09:21:46.641923+00:00 app[web.1]: paste: None
2021-08-18T09:21:46.642453+00:00 app[web.1]: on_starting: <function OnStarting.on_starting at 0x7fef7fcbb9d0>
2021-08-18T09:21:46.642454+00:00 app[web.1]: on_reload: <function OnReload.on_reload at 0x7fef7fcbbaf0>
2021-08-18T09:21:46.642454+00:00 app[web.1]: when_ready: <function WhenReady.when_ready at 0x7fef7fcbbc10>
2021-08-18T09:21:46.642455+00:00 app[web.1]: pre_fork: <function Prefork.pre_fork at 0x7fef7fcbbd30>
2021-08-18T09:21:46.642455+00:00 app[web.1]: post_fork: <function Postfork.post_fork at 0x7fef7fcbbe50>
2021-08-18T09:21:46.642455+00:00 app[web.1]: post_worker_init: <function PostWorkerInit.post_worker_init at 0x7fef7fcbbf70>
2021-08-18T09:21:46.642456+00:00 app[web.1]: worker_int: <function WorkerInt.worker_int at 0x7fef7fccc0d0>
2021-08-18T09:21:46.642456+00:00 app[web.1]: worker_abort: <function WorkerAbort.worker_abort at 0x7fef7fccc1f0>
2021-08-18T09:21:46.642456+00:00 app[web.1]: pre_exec: <function PreExec.pre_exec at 0x7fef7fccc310>
2021-08-18T09:21:46.642457+00:00 app[web.1]: pre_request: <function PreRequest.pre_request at 0x7fef7fccc430>
2021-08-18T09:21:46.642457+00:00 app[web.1]: post_request: <function PostRequest.post_request at 0x7fef7fccc4c0>
2021-08-18T09:21:46.642458+00:00 app[web.1]: child_exit: <function ChildExit.child_exit at 0x7fef7fccc5e0>
2021-08-18T09:21:46.642458+00:00 app[web.1]: worker_exit: <function WorkerExit.worker_exit at 0x7fef7fccc700>
2021-08-18T09:21:46.642458+00:00 app[web.1]: nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7fef7fccc820>
2021-08-18T09:21:46.642459+00:00 app[web.1]: on_exit: <function OnExit.on_exit at 0x7fef7fccc940>
2021-08-18T09:21:46.642459+00:00 app[web.1]: proxy_protocol: False
2021-08-18T09:21:46.642459+00:00 app[web.1]: proxy_allow_ips: ['127.0.0.1']
2021-08-18T09:21:46.642460+00:00 app[web.1]: keyfile: None
2021-08-18T09:21:46.642460+00:00 app[web.1]: certfile: None
2021-08-18T09:21:46.642460+00:00 app[web.1]: ssl_version: 2
2021-08-18T09:21:46.642461+00:00 app[web.1]: cert_reqs: 0
2021-08-18T09:21:46.642461+00:00 app[web.1]: ca_certs: None
2021-08-18T09:21:46.642461+00:00 app[web.1]: suppress_ragged_eofs: True
2021-08-18T09:21:46.642462+00:00 app[web.1]: do_handshake_on_connect: False
2021-08-18T09:21:46.642462+00:00 app[web.1]: ciphers: None
2021-08-18T09:21:46.642462+00:00 app[web.1]: raw_paste_global_conf: []
2021-08-18T09:21:46.642463+00:00 app[web.1]: strip_header_spaces: False
2021-08-18T09:21:46.643622+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-08-18T09:21:46.644633+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [DEBUG] Arbiter booted
2021-08-18T09:21:46.644821+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Listening at: http://0.0.0.0:44920 (4)
2021-08-18T09:21:46.645051+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Using worker: sync
2021-08-18T09:21:46.652069+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [7] [INFO] Booting worker with pid: 7
2021-08-18T09:21:46.662712+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [7] [ERROR] Exception in worker process
2021-08-18T09:21:46.662715+00:00 app[web.1]: Traceback (most recent call last):
2021-08-18T09:21:46.662715+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-08-18T09:21:46.662716+00:00 app[web.1]: worker.init_process()
2021-08-18T09:21:46.662716+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-08-18T09:21:46.662717+00:00 app[web.1]: self.load_wsgi()
2021-08-18T09:21:46.662717+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-08-18T09:21:46.662718+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-08-18T09:21:46.662718+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-08-18T09:21:46.662718+00:00 app[web.1]: self.callable = self.load()
2021-08-18T09:21:46.662719+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-08-18T09:21:46.662719+00:00 app[web.1]: return self.load_wsgiapp()
2021-08-18T09:21:46.662719+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-08-18T09:21:46.662720+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-08-18T09:21:46.662720+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2021-08-18T09:21:46.662720+00:00 app[web.1]: mod = importlib.import_module(module)
2021-08-18T09:21:46.662721+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2021-08-18T09:21:46.662721+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-08-18T09:21:46.662722+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2021-08-18T09:21:46.662722+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2021-08-18T09:21:46.662723+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2021-08-18T09:21:46.662723+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2021-08-18T09:21:46.662723+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2021-08-18T09:21:46.662724+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2021-08-18T09:21:46.662724+00:00 app[web.1]: File "/app/ToDoApps/wsgi.py", line 12, in <module>
2021-08-18T09:21:46.662725+00:00 app[web.1]: from django.core.wsgi import get_wsgi_application
2021-08-18T09:21:46.662725+00:00 app[web.1]: ModuleNotFoundError: No module named 'django'
2021-08-18T09:21:46.662924+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-08-18T09:21:46.707594+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Shutting down: Master
2021-08-18T09:21:46.707848+00:00 app[web.1]: [2021-08-18 09:21:46 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-08-18T09:21:46.836081+00:00 heroku[web.1]: Process exited with status 3
2021-08-18T09:21:47.118125+00:00 heroku[web.1]: State changed from starting to crashed

Procfile

web: gunicorn ToDoApps.wsgi

settings.py

from pathlib import Path
import os
import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-z913vx8_t5o#ahodt51t37t4-*9ytn3k*@zi%)lcl26wq=v2k3'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['*'] #new

# Application definition
INSTALLED_APPS = [
'whitenoise.runserver_nostatic', #New
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
#'whitenoise.runserver_nostatic',#New
'django.contrib.staticfiles',
'second',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',

'whitenoise.middleware.WhiteNoiseMiddleware', #new
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'ToDoApps.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'ToDoApps.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
WHITENOISE_USE_FINDERS = True #New
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') #New!
STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
#STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' #new!
#New start
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
#New End

修改几下就可以了。我错过了运行python3 manage.py collectstatic。然后推到github。我在部署之前删除了构建包。并遵循本教程https://www.codechit.com/django-github-auto-deployment-to-heroku/

相关内容

最新更新