我正在嘗試將燒瓶應用程式部署到 App Engine 標準。
該應用程式在我的本地機器上運行良好。
它還可以部署到應用引擎。
但是,當我請求 URL 時,頁面未加載,并且日志中出現以下訊息:
App Engine: Process terminated because the request deadline was exceeded. Please ensure that your HTTP server is listening for requests on 0.0.0.0 and on the port defined by the PORT environment variable. (Error code 123)
我不會共享整個應用程式的代碼,但我在其中使用了以下 app.run 命令:
if __name__ == '__main__':
app.run(host='0.0.0.0')
此外,以下是 GCP 日志資源管理器中截止時間超出訊息點之前的所有日志訊息:
2022-07-26 11:47:00.542 BST
App Initialising
2022-07-26 11:47:00.544 BST
* Serving Flask app 'app' (lazy loading)
2022-07-26 11:47:00.544 BST
* Environment: production
2022-07-26 11:47:00.544 BST
WARNING: This is a development server. Do not use it in a production deployment.
2022-07-26 11:47:00.544 BST
Use a production WSGI server instead.
2022-07-26 11:47:00.544 BST
* Debug mode: off
2022-07-26 11:47:00.556 BST
* Running on all addresses (0.0.0.0)
2022-07-26 11:47:00.556 BST
WARNING: This is a development server. Do not use it in a production deployment.
2022-07-26 11:47:00.556 BST
* Running on http://127.0.0.1:5000
2022-07-26 11:47:00.556 BST
* Running on http://169.254.8.1:5000 (Press CTRL C to quit)
2022-07-26 11:49:31.899 BST
[start] 2022/07/26 10:49:31.898979 Quitting on terminated signal
2022-07-26 11:49:31.899 BST
[start] 2022/07/26 10:49:31.899629 Start program failed: failed to detect app after start: ForAppStart(): [aborted, context canceled. subject:"app/valid" Timeout:30m0s, attempts:119910 aborted, context canceled. subject:"app/invalid" Timeout:30m0s, attempts:119886]
在這里,我測驗 GET 請求應用程式主頁:
2022-07-26 11:50:43.136 BST
GET 500 301.663 s Chrome 103.0.0.0 /
188.221.25.131 - - [26/Jul/2022:03:50:43 -0700] GET / HTTP/1.1 500 - - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" "<<app url>>" ms=301663 cpu_ms=0 cpm_usd=0 loading_request=0 instance=00c61b117cc57f1885aa1e4f9a85f795df32ab91d3ed079eeaf27721ad7817ec20ebabd30ca9d4226dd67175724a624eba33cd2da0023671d18f app_engine_release=1.9.71 trace_id=2ef242690a4b068b13493764e6279eb2
導致超時訊息:
**2022-07-26 11:55:44.799 BST
Process terminated because the request deadline was exceeded. Please ensure that your HTTP server is listening for requests on 0.0.0.0 and on the port defined by the PORT environment variable. (Error code 123)**
有誰知道可能是什么問題?或者誰能??指出我進一步探索的正確方向?
uj5u.com熱心網友回復:
app.run
必須將埠值更改為8080
,如@John Hanley 評論所示:
默認埠是 8080。Flask 偵聽埠 5000。更改您的代碼:
app.run(host='0.0.0.0', port=8080)
如Flask 檔案所示,Flask 在埠上運行5000
:
要運行應用程式,請使用flask命令...
$ flask run * Running on http://127.0.0.1:5000/
因此,必須將其更改為在 port 上運行8080
,如在App Engine 柔性環境檔案示例代碼中創建 Python 應用中所述:
# This is used when running locally only. When deploying to Google App
# Engine, a webserver process such as Gunicorn will serve the app. This
# can be configured by adding an `entrypoint` to app.yaml.
# Flask's development server will automatically serve static files in
# the "static" directory. See:
# http://flask.pocoo.org/docs/1.0/quickstart/#static-files. Once deployed,
# App Engine itself will serve those files as configured in app.yaml.
app.run(host='127.0.0.1', port=8080, debug=True)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/507758.html
標籤:Google Cloud Collective 烧瓶 谷歌应用引擎 谷歌云平台 谷歌应用引擎 python