##前提
LINE BOTをherokuを使い開発しようとしています。
言語はPythonで、flaskを使用しています。
今の状況として、Herokuにデプロイした際エラーが発生し、LINE BOTが上手く動いてくれません。
具体的には後述しますが、どうやらログを確認するとアプリがクラッシュしているらしいのですが、インターネットで調べても解決方法がよくわからないので質問させて頂きました。
##使用環境
Windows10
Python 3.6.4
Flask 1.0.2
line-bot-sdk 1.8.0
##エラー内容
Herokuのログを確認しました。
以下にそのログを添付します。文字数がオーバーしたので一部省略したほか、アクセストークンなど機密なものは省かせて頂きました。
2019-02-06T12:36:05.819172+00:00 app[web.1]: raise KeyError(key) from None 2019-02-06T12:36:05.819178+00:00 app[web.1]: KeyError: '秘密です' 2019-02-06T12:37:04.440904+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/callback" host=pepar-iot.herokuapp.com request_id=5323c15e-10a6-4ea3-a8ad-79802d1d9687 fwd="203.104.156.75" dyno= connect= service= status=503 bytes= protocol=https 2019-02-06T12:42:19.319243+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T12:42:26.630365+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T12:42:26.607177+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T12:42:26.426662+00:00 app[web.1]: Traceback (most recent call last): 2019-02-06T12:42:26.426757+00:00 app[web.1]: File "main.py", line 17, in <module> 2019-02-06T12:42:26.427107+00:00 app[web.1]: YOUR_CHANNEL_ACCESS_TOKEN = os.environ["秘密です"] 2019-02-06T12:42:26.427145+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/os.py", line 669, in __getitem__ 2019-02-06T12:42:26.427876+00:00 app[web.1]: raise KeyError(key) from None 2019-02-06T12:42:26.427963+00:00 app[web.1]: KeyError: '秘密です' 2019-02-06T12:42:27.000000+00:00 app[api]: Build succeeded 2019-02-06T12:49:59.896083+00:00 heroku[web.1]: Starting process with command `python main.py` 2019-02-06T12:50:04.691422+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T12:50:04.576959+00:00 app[web.1]: Traceback (most recent call last): 2019-02-06T12:50:04.576989+00:00 app[web.1]: File "main.py", line 17, in <module> 2019-02-06T12:50:04.577200+00:00 app[web.1]: YOUR_CHANNEL_ACCESS_TOKEN = os.environ["秘密です"] 2019-02-06T12:50:04.577244+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/os.py", line 669, in __getitem__ 2019-02-06T12:50:04.577825+00:00 app[web.1]: raise KeyError(key) from None 2019-02-06T12:50:04.577877+00:00 app[web.1]: KeyError: '秘密です' 2019-02-06T13:19:12.312706+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T13:43:07.000000+00:00 app[api]: Build started by user 2019-02-06T13:43:25.134084+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T13:43:30.188999+00:00 heroku[web.1]: Starting process with command `python main.py` 2019-02-06T13:43:33.599273+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T13:43:33.610922+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T13:43:33.579154+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T13:43:33.000000+00:00 app[api]: Build succeeded 2019-02-06T13:43:41.374314+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T13:43:41.356404+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T13:44:01.473609+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/callback" host=pepar-iot.herokuapp.com request_id=70346ed8-a99d-442e-b7bc-8d8198095b1d fwd="203.104.156.75" dyno= connect= service= status=503 bytes= protocol=https 2019-02-06T13:48:18.580853+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pepar-iot.herokuapp.com request_id=ea258357-1abc-4360-ba7b-2a0dc7a42561 fwd="153.191.145.162" dyno= connect= service= status=503 bytes= protocol=https 2019-02-06T13:48:18.861716+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pepar-iot.herokuapp.com request_id=a9dedbae-0abb-4333-956b-bc2dc6cb472a fwd="153.191.145.162" dyno= connect= service= status=503 bytes= protocol=https 2019-02-06T14:02:37.000000+00:00 app[api]: Build started by user 2019-02-06T14:02:53.688380+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T14:02:57.405159+00:00 heroku[web.1]: Starting process with command `python main.py` 2019-02-06T14:03:01.935575+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T14:03:01.945075+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T14:03:01.782734+00:00 app[web.1]: Traceback (most recent call last): 2019-02-06T14:03:01.782772+00:00 app[web.1]: File "main.py", line 17, in <module> 2019-02-06T14:03:01.782949+00:00 app[web.1]: YOUR_CHANNEL_ACCESS_TOKEN = os.environ["秘密です"] 2019-02-06T14:03:01.782987+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/os.py", line 669, in __getitem__ 2019-02-06T14:03:01.783541+00:00 app[web.1]: raise KeyError(key) from None 2019-02-06T14:03:01.783610+00:00 app[web.1]: KeyError: '秘密です' 2019-02-06T14:02:53.512862+00:00 app[api]: Deploy 6e1b4d94 by user 秘密です 2019-02-06T14:02:53.512862+00:00 app[api]: Release v31 created by user 秘密です。 2019-02-06T14:03:06.509968+00:00 heroku[web.1]: Starting process with command `python main.py` 2019-02-06T14:03:10.504901+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T14:05:20.832320+00:00 app[api]: Release v32 created by user 秘密です。 2019-02-06T14:05:29.818349+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T14:06:12.982316+00:00 app[api]: Release v33 created by user 秘密です 2019-02-06T14:06:12.982316+00:00 app[api]: Set YOUR_CHANNEL_ACCESS_TOKEN config vars by user 秘密です。 2019-02-06T14:06:17.429013+00:00 heroku[web.1]: Starting process with command `python main.py` 2019-02-06T14:06:20.943509+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T14:15:08.391975+00:00 heroku[web.1]: Starting process with command `python main.py` 2019-02-06T14:39:17.363005+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T14:41:44.519529+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T14:41:44.191622+00:00 app[api]: @ref:fixie-animated-11261 completed provisioning, setting FIXIE_URL. by user 秘密です。 2019-02-06T14:41:44.191622+00:00 app[api]: Release v35 created by user 秘密です。 2019-02-06T14:41:44.176761+00:00 app[api]: Running release v34 commands by user 秘密です。 2019-02-06T14:41:50.002528+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T14:43:33.454006+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T14:43:33.126067+00:00 app[api]: Deploy d5b45690 by user 秘密です 2019-02-06T14:43:40.186296+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T14:43:40.068719+00:00 app[web.1]: Traceback (most recent call last): 2019-02-06T14:43:40.068795+00:00 app[web.1]: File "main.py", line 17, in <module> 2019-02-06T14:43:40.068919+00:00 app[web.1]: YOUR_CHANNEL_ACCESS_TOKEN = os.environ["秘密です"] 2019-02-06T14:43:40.068925+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/os.py", line 678, in __getitem__ 2019-02-06T14:43:40.069257+00:00 app[web.1]: raise KeyError(key) from None 2019-02-06T14:43:40.069312+00:00 app[web.1]: KeyError: '秘密です' 2019-02-06T14:53:17.066473+00:00 heroku[web.1]: Starting process with command `python main.py` 2019-02-06T14:53:19.516876+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T15:14:26.125193+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T15:14:25.397710+00:00 app[api]: Deploy 7ff13bdb by user 秘密です 2019-02-06T15:14:33.350265+00:00 heroku[web.1]: State changed from starting to crashed 2019-02-06T15:14:33.332870+00:00 heroku[web.1]: Process exited with status 1 2019-02-06T15:14:33.207189+00:00 app[web.1]: Traceback (most recent call last): 2019-02-06T15:14:33.207211+00:00 app[web.1]: File "main.py", line 17, in <module> 2019-02-06T15:14:33.207415+00:00 app[web.1]: YOUR_CHANNEL_ACCESS_TOKEN = os.environ["秘密です"] 2019-02-06T15:14:33.207422+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/os.py", line 669, in __getitem__ 2019-02-06T15:14:33.207696+00:00 app[web.1]: raise KeyError(key) from None 2019-02-06T15:14:33.207765+00:00 app[web.1]: KeyError: '秘密です' 2019-02-06T15:34:42.758391+00:00 heroku[web.1]: State changed from crashed to starting 2019-02-06T15:34:42.482777+00:00 app[web.1]: Traceback (most recent call last): 2019-02-06T15:34:42.482800+00:00 app[web.1]: File "main.py", line 17, in <module> 2019-02-06T15:34:42.483034+00:00 app[web.1]: YOUR_CHANNEL_ACCESS_TOKEN = os.environ["秘密です"] 2019-02-06T15:34:42.483073+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/os.py", line 669, in __getitem__
おそらくアプリが正常に動かない原因と思われるエラーを上記のログから抜粋します。
2019-02-06T13:44:01.473609+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/callback" host=pepar-iot.herokuapp.com request_id=70346ed8-a99d-442e-b7bc-8d8198095b1d fwd="203.104.156.75" dyno= connect= service= status=503 bytes= protocol=https 2019-02-06T13:48:18.580853+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pepar-iot.herokuapp.com request_id=ea258357-1abc-4360-ba7b-2a0dc7a42561 fwd="153.191.145.162" dyno= connect= service= status=503 bytes= protocol=https 2019-02-06T13:48:18.861716+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pepar-iot.herokuapp.com request_id=a9dedbae-0abb-4333-956b-bc2dc6cb472a fwd="153.191.145.162" dyno= connect= service= status=503 bytes= protocol=https
以下はこのアプリのプログラム(Python)の
if name == __main__の部分です。
python
1if __name__ == "__main__": 2 port = int(os.getenv("PORT")) 3 app.run(host="0.0.0.0", port=port)
解決方法を教えて頂きたいです。
質問内容に不備がある場合は補足させていただきますので、その際はコメントして頂くと幸いです。
回答1件
あなたの回答
tips
プレビュー