前提・実現したいこと
herokuにてhello worldと表示させたいです。
発生している問題・エラーメッセージ
https://qiita.com/redpanda/items/a056daea48b545250ce7
上記のサイトを参考にデプロイを試みたのですがアプリの起動を行うときにエラーが出てき、何が原因かわからない状況です。
アプリをheroku openで起動しようとしたときこの画面が出てきてアプリが動きませんでした
※追加情報
最新のheroku logs --tailを追加します。
2020-12-27T05:22:29.122077+00:00 app[web.1]: [2020-12-27 05:22:29 +0000] [8] [INFO] Booting worker with pid: 8 : [2020-12-27 05:22:29 +0000] [8] [ERROR] Exception in worker process : Traceback (most recent call last): : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker : worker.init_process() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 119, in init_process : self.load_wsgi() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi : self.wsgi = self.app.wsgi() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi : self.callable = self.load() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 49, in load : return self.load_wsgiapp() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp : return util.import_app(self.app_uri) : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 358, in import_app : mod = importlib.import_module(module) : File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module : return _bootstrap._gcd_import(name[level:], package, level) : File "<frozen importlib._bootstrap>", line 1030, in _gcd_import : File "<frozen importlib._bootstrap>", line 1007, in _find_and_load : File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked : File "<frozen importlib._bootstrap>", line 680, in _load_unlocked : File "<frozen importlib._bootstrap_external>", line 786, in exec_module : File "<frozen importlib._bootstrap_external>", line 923, in get_code : File "<frozen importlib._bootstrap_external>", line 853, in source_to_code : File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed : File "/app/app.py", line 13 : app.run(debug=False, host='0.0.0.0', port=int(os.environ.get('PORT', 5000))) : ^ : IndentationError: expected an indented block : [2020-12-27 05:22:29 +0000] [8] [INFO] Worker exiting (pid: 8) : [2020-12-27 05:22:29 +0000] [9] [INFO] Booting worker with pid: 9 : [2020-12-27 05:22:29 +0000] [9] [ERROR] Exception in worker process : Traceback (most recent call last): : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker : worker.init_process() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 119, in init_process : self.load_wsgi() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi : self.wsgi = self.app.wsgi() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi : self.callable = self.load() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 49, in load : return self.load_wsgiapp() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp : return util.import_app(self.app_uri) : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 358, in import_app : mod = importlib.import_module(module) : File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module : return _bootstrap._gcd_import(name[level:], package, level) : File "<frozen importlib._bootstrap>", line 1030, in _gcd_import : File "<frozen importlib._bootstrap>", line 1007, in _find_and_load : File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked : File "<frozen importlib._bootstrap>", line 680, in _load_unlocked : File "<frozen importlib._bootstrap_external>", line 786, in exec_module : File "<frozen importlib._bootstrap_external>", line 923, in get_code : File "<frozen importlib._bootstrap_external>", line 853, in source_to_code : File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed : File "/app/app.py", line 13 : app.run(debug=False, host='0.0.0.0', port=int(os.environ.get('PORT', 5000))) : ^ : IndentationError: expected an indented block : [2020-12-27 05:22:29 +0000] [9] [INFO] Worker exiting (pid: 9) : Traceback (most recent call last): : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 209, in run : self.sleep() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 357, in sleep : ready = select.select([self.PIPE[0]], [], [], 1.0) : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld : self.reap_workers() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers : raise HaltServer(reason, self.WORKER_BOOT_ERROR) : gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3> : : During handling of the above exception, another exception occurred: : : Traceback (most recent call last): : File "/app/.heroku/python/bin/gunicorn", line 8, in <module> : sys.exit(run()) : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in run : WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 228, in run : super().run() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 72, in run : Arbiter(self).run() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 229, in run : self.halt(reason=inst.reason, exit_status=inst.exit_status) : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 342, in halt : self.stop() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 393, in stop : time.sleep(0.1) : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld : self.reap_workers() : File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers : raise HaltServer(reason, self.WORKER_BOOT_ERROR) 2020-12-27T05:22:29.206571+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3> 2020-12-27T05:22:29.307883+00:00 heroku[web.1]: Process exited with status 1 2020-12-27T05:22:29.357867+00:00 heroku[web.1]: State changed from starting to crashed 2020-12-27T05:22:41.286778+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=kyunai2.herokuapp.com request_id=cc7a5864-553c-4a66-885f-ce92e04c93a1 fwd="113.153.101.89" dyno= connect= service= status=503 bytes= protocol=https
該当のソースコード
コードを新しくしたので新しく編集します
app.py
from flask import Flask import os app = Flask(__name__) @app.route('/') def index(): return 'hello, world' if __name__ == '__main__': app.run(debug=False, host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))
Procfile
web: gunicorn app:app --log-file=-
requirements.txt
click==7.1.2 Flask==1.1.2 gunicorn==20.0.4 itsdangerous==1.1.0 Jinja2==2.11.2 MarkupSafe==1.1.1 Werkzeug==1.0.1
runtime.txt
python-3.9.0
試したこと
gitに正しくアップロードされているか確認するためにgit cloneを行い、ファイルの比較を行った結果、正しくアップロードできていることが確認できました。
また、herokuのアプリ管理画面でBuild succeededとなっていることは確認できました
補足情報にビルドログを記述しておきます。
procfileを以下のように書き換えて実行もしてみましたが、変わらずエラーが出てしまいました。
web: python app.py
補足情報(FW/ツールのバージョンなど)
VSCode : 1.52.1
※追記
Procfileに問題があることが分かったのですが元の記事のようにしてもエラーが出ます
アプリ側のこの写真のところで何かすることがありますか?