首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gunicorn命令行错误inGoogle应用引擎标准环境

Gunicorn命令行错误inGoogle应用引擎标准环境
EN

Stack Overflow用户
提问于 2018-12-12 11:52:55
回答 2查看 542关注 0票数 0

在将Flask/Python3/Postgres应用程序部署到应用程序引擎标准环境后,我收到了无穷无尽的以下错误。关于Psycopg2包的警告值得关注,但不是导致应用程序无法运行的原因。相反,这是GAE提供的GAE提供的无效命令行参数,而不是我提供的。有人能够成功地将使用Postgres的Python3 Flask部署到标准环境中吗?

以下是日志文件输出:

代码语言:javascript
复制
2018-12-11 02:51:37 +0000] [3738] [INFO] Booting worker with pid: 3738
2018-12-11 02:51:37 default[20181210t140744]  /env/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-12-11 02:51:37 default[20181210t140744]    """)
2018-12-11 02:51:38 default[20181210t211942]  usage: gunicorn [-h] [--debug] [--args]
2018-12-11 02:51:38 default[20181210t211942]  gunicorn: error: unrecognized arguments: main:app --workers 1 -c /config/gunicorn.py
2018-12-11 02:51:38 default[20181210t211942]  [2018-12-11 02:51:38 +0000] [882] [INFO] Worker exiting (pid: 882)
EN

回答 2

Stack Overflow用户

发布于 2018-12-12 16:52:41

默认情况下,如果app.yaml中没有定义entrypoint,App Engine将在main.py中查找名为app的应用。如果您查看Github中的官方代码示例,它会在main.py文件中声明:

代码语言:javascript
复制
app = Flask(__name__)

或者,可以通过向指向另一个文件的app.yaml添加一个entrypoint来配置它。例如,如果在名为prod的文件中声明app:

代码语言:javascript
复制
entrypoint: gunicorn -b :$PORT prod.app

您将找到有关入口点配置here的其他详细信息。

票数 1
EN

Stack Overflow用户

发布于 2018-12-13 03:38:12

从上面的评论和答案来看,问题看起来一定是我的应用程序出了问题。我确认了这一点,在一个简单的应用程序上本地运行gunicorn没有遇到困难,但在运行真正的应用程序时失败了。

其中一个罪魁祸首是使用argparse,我之所以使用argparse,是因为在本地工作时,我可以在命令行中添加"debug“参数。将该代码移到if __name__ == '__main__':部分,使应用程序在本地使用gunicorn时运行良好。

但它在部署到GAE时仍然会失败:

代码语言:javascript
复制
2018-12-12 20:09:16 default[20181212t094625]  [2018-12-12 20:09:16 +0000] [8145] [INFO] Booting worker with pid: 8145
2018-12-12 20:09:16 default[20181212t094625]  /env/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-12-12 20:09:16 default[20181212t094625]    """)
2018-12-12 20:09:16 default[20181212t094625]  [2018-12-12 20:09:16 +0000] [8286] [INFO] Booting worker with pid: 8286
2018-12-12 20:09:16 default[20181212t094625]  /env/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-12-12 20:09:16 default[20181212t094625]    """)
2018-12-12 20:09:19 default[20181212t094625]  usage: gunicorn [-h] [--debug] [--args]
2018-12-12 20:09:19 default[20181212t094625]  gunicorn: error: unrecognized arguments: -b :8081 main:app
2018-12-12 20:09:19 default[20181212t094625]  [2018-12-12 20:09:19 +0000] [8145] [INFO] Worker exiting (pid: 8145)

下面是app.yaml (去掉SendGrid的环境变量):

代码语言:javascript
复制
runtime: python37
env: standard
#threadsafe: true
entrypoint: gunicorn --workers 2 --bind :5000 main:app

#runtime_config:
#  python_version: 3

# This beta setting is necessary for the db hostname parameter to be able to handle a URI in the
# form “/cloudsql/...” where ... is the instance given here:
beta_settings:
    cloud_sql_instances: provost-access-148820:us-east1:cuny-courses
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53735812

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档