【发布时间】:2022-11-05 20:26:38
【问题描述】:
我想运行一个 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 在多个实例中运行导致此错误。如果没有,那么请帮助解决这个问题。
【问题讨论】:
-
看看这是否有帮助 - stackoverflow.com/a/73196295/15211203
-
现在它说
Port 8080 is in use by another program. Either identify and stop that program, or start the server with a different port.....请帮助...
标签: google-app-engine google-app-engine-python