【问题标题】:Errors with deploying website using Heroku/Flask Server使用 Heroku/Flask Server 部署网站时出错
【发布时间】:2018-11-19 07:45:18
【问题描述】:

我正在尝试使用 Flask/SQLAlchemy 部署一个网站,以使用女服务员托管我的数据库。我确实尝试关注此链接,但我认为我的文件结构不一样 Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)

这是我的文件结构

Server
->BarBeerDrinker
 ->__pycache__
 ->static
 ->__init__.py
 ->configt.py
 ->database.py
->app.py
->Procfile
->requirements.txt

尝试访问我的网站后,我在控制台中输入heroku log --tail,这就是我得到的。

2018-11-18T22:55:29.243807+00:00 heroku[web.1]: State changed from starting to crashed
2018-11-18T22:55:29.245456+00:00 heroku[web.1]: State changed from crashed to starting
2018-11-18T22:55:29.216028+00:00 heroku[web.1]: Process exited with status 1
2018-11-18T22:55:32.860988+00:00 heroku[web.1]: Starting process with command `waitress-serve --port=$8080 app:app`
2018-11-18T22:55:35.124713+00:00 app[web.1]: Traceback (most recent call last):
2018-11-18T22:55:35.124735+00:00 app[web.1]: File "/app/.heroku/python/bin/waitress-serve", line 11, in <module>
2018-11-18T22:55:35.124898+00:00 app[web.1]: sys.exit(run())
2018-11-18T22:55:35.124904+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/waitress/runner.py", line 274, in run
2018-11-18T22:55:35.125138+00:00 app[web.1]: _serve(app, **kw)
2018-11-18T22:55:35.125140+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/waitress/__init__.py", line 11, in serve
2018-11-18T22:55:35.125264+00:00 app[web.1]: server = _server(app, **kw)
2018-11-18T22:55:35.125270+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/waitress/server.py", line 85, in create_server
2018-11-18T22:55:35.125426+00:00 app[web.1]: sockinfo=sockinfo)
2018-11-18T22:55:35.125432+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/waitress/server.py", line 182, in __init__
2018-11-18T22:55:35.125614+00:00 app[web.1]: self.bind_server_socket()
2018-11-18T22:55:35.125616+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/waitress/server.py", line 294, in bind_server_socket
2018-11-18T22:55:35.125854+00:00 app[web.1]: self.bind(sockaddr)
2018-11-18T22:55:35.125857+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/asyncore.py", line 329, in bind
2018-11-18T22:55:35.126090+00:00 app[web.1]: return self.socket.bind(addr)
2018-11-18T22:55:35.126120+00:00 app[web.1]: PermissionError: [Errno 13] Permission denied
2018-11-18T22:55:35.308901+00:00 heroku[web.1]: State changed from starting to crashed
2018-11-18T22:55:35.259026+00:00 heroku[web.1]: Process exited with status 1
2018-11-18T22:55:53.439739+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-sea-95736.herokuapp.com request_id=9afddc5b-75fe-4437-bd85-8ec0abf6dbb3 fwd="128.6.37.227" dyno= connect= service= status=503 bytes= protocol=https
2018-11-18T22:55:53.925888+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-sea-95736.herokuapp.com request_id=29b560a2-e0d3-4814-afdd-51e767c375f9 fwd="128.6.37.227" dyno= connect= service= status=503 bytes= protocol=https
2018-11-18T22:59:39.925553+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=safe-sea-95736.herokuapp.com request_id=3633f1d0-3961-453d-b62f-8d9ba9790bfa fwd="128.6.37.227" dyno= connect= service= status=503 bytes= protocol=https
2018-11-18T22:59:40.329280+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=safe-sea-95736.herokuapp.com request_id=c1b91fc0-e2b9-41d6-9ad7-9c02033b16a2 fwd="128.6.37.227" dyno= connect= service= status=503 bytes= protocol=https

我对尝试部署网站非常陌生,老实说,我只是按照我的教授在这里给我们的基本指导进行操作 https://drive.google.com/file/d/1dltcKrigTvtJk3hHvl7I_y0KnlGuy3V9/view?usp=sharing

【问题讨论】:

    标签: python node.js heroku flask waitress


    【解决方案1】:

    PermissionError 表示您可能需要授予文件可执行权限。尝试向runner.py 和/或server.py 授予权限。

    chmod 777 /path/to/runner.py
    chmod 777 /path/to/server.py
    

    777 将授予所有者/组/其他广泛的读/写/执行权限。你可能想要更具体的东西,比如chmod 755 path/to/file.py。请参阅 chmod here 的手册页。

    【讨论】:

    • 我试过了,它确实删除了权限错误代码,但应用程序仍然崩溃。此外,我有 Windows 机器,并且所有权限都授予它。
    • 看看这在你的 procfile 中是否有效:waitress-serve --port=$PORT app:app
    • 我们被告知使用 |网络:服务员服务 --port=$PORT 应用程序:应用程序 |
    • 是的,看起来是正确的(使用web:)。我在您的 Heroku 日志中看到:Starting process with command waitress-serve --port=$8080 app:app。所以只要确保你定义了--port=$PORT
    • 所以最初我们的 $PORT 被定义为 8080,我把它改回了 $PORT。现在我们减少了错误,剩下的就是 at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=warm-ridge-64023.herokuapp.com request_id= 81bbac98-b2a2-4f69-8a09-acd8f438e2d2 fwd="128.6.37.249" dyno= connect= service= status=503 bytes= protocol=https
    猜你喜欢
    • 2015-04-28
    • 1970-01-01
    • 2016-12-21
    • 2016-02-15
    • 2013-06-20
    • 2020-07-01
    • 2021-12-31
    • 1970-01-01
    • 2013-12-02
    相关资源
    最近更新 更多