我想運行一個 python flask hello world。我部署到 App Engine,但它顯示的好像是說該埠正在使用中,并且看起來它同時在多個實體/執行緒/克隆上運行。
這是我的 main.py
from flask import Flask
app = Flask(__name__)
@app.route('/hello')
def helloIndex():
print("Hello world log console")
return 'Hello World from Python Flask!'
app.run(host='0.0.0.0', port=4444)
這是我的 app.yaml
runtime: python38
env: standard
instance_class: B2
handlers:
- url: /
script: auto
- url: .*
script: auto
manual_scaling:
instances: 1
這是我的要求.txt
gunicorn==20.1.0
flask==2.2.2
這是我得到的日志:
* Serving Flask app 'main'
* Debug mode: off
Address already in use
Port 4444 is in use by another program. Either identify and stop that program, or start the server with a different port.
[2022-08-10 15:57:28 0000] [1058] [INFO] Worker exiting (pid: 1058)
[2022-08-10 15:57:29 0000] [1059] [INFO] Booting worker with pid: 1059
[2022-08-10 15:57:29 0000] [1060] [INFO] Booting worker with pid: 1060
[2022-08-10 15:57:29 0000] [1061] [INFO] Booting worker with pid: 1061
它說埠 4444 正在使用中。最初我嘗試了 5000(flask 的默認埠),但它說它正在使用中。我也嘗試洗掉port=4444
但現在它說Port 5000 is in use by another program
,我猜燒瓶默認分配埠 = 5000。我懷疑這是因為 GAE 在多個實體中運行導致此錯誤。如果沒有,那么請幫助解決這個問題。
uj5u.com熱心網友回復:
App Engine 應用應偵聽埠 8080,而不是任何其他埠。
所以你可能需要像這樣設定
app.run(host='0.0.0.0', port=8080)
uj5u.com熱心網友回復:
我想到了。從您的終端和/或創建 Web 應用程式的檔案夾中洗掉您的舊檔案。在終端中,這是通過以下方式完成的:
rm -file_name
然后用你的新檔案再試一次,應該沒問題。
uj5u.com熱心網友回復:
關閉編輯器,然后重新打開。下次停止行程時,如果您在終端上,請使用 Ctrl C
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/529118.html
標籤:Google Cloud Collective 谷歌应用引擎谷歌应用引擎 python
上一篇:嘗試從部署在AppEngineStandard上的Symfony應用程式連接到CloudSQL時出現“連接被拒絕”