【问题标题】:Google App Engine Standard can not find/execute GunicornGoogle App Engine Standard 找不到/执行 Gunicorn
【发布时间】:2019-06-20 19:03:47
【问题描述】:

我有一个带有 Django 后端和 Angular 前端的项目。我已将它们作为两个服务部署到 Google App Engine Standard 中,并且部署成功

但是,当我尝试访问后端 url this-backend.appspot.com 时,我得到了

/bin/sh: 1: exec: gunicorn: not found

我的需求文件中有 gunicorn

gunicorn==19.9.0

我也定义了入口点:

runtime: python37
service: default

entrypoint: gunicorn -b :$PORT thisapp.wsgi

handlers:
- url: /static
  static_dir: static
- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto

但仍然得到同样的错误。

我在 Stackoverflow 上查看了所有相同的问题,它们要么是因为需求,要么是我定义了它们的入口点。

即使我转到 Stackdriver,我也可以看到 app engine:/ 中的 gunicorn 文件夹:

gunicorn
gunicorn-19.9.0.dist-info

这是后端cloudbuild.yaml文件:

steps:

  - name: 'python:3.7'                                                                                                                               
    entrypoint: python3                                                               
    args: ['-m', 'pip', 'install', '-t', '.', '-r', 'requirements.txt'] 

  - name: 'python:3.7'                                                            
    entrypoint: python3                                                           
    args: ['./manage.py', 'collectstatic', '--noinput']

  - name: 'gcr.io/cloud-builders/gcloud'
    args: ['app', 'deploy', '--version=prod']

如果有人有任何解决方案或建议,我将不胜感激,因为我在互联网上研究了几乎所有相同的问题。

谢谢,

詹姆斯

【问题讨论】:

    标签: django google-app-engine gunicorn google-cloud-build


    【解决方案1】:

    默认情况下,App Engine 会在 app 目录的根目录中查找 main.py 文件,其中包含一个名为 app 的 WSGI 兼容对象。

    文档here 建议如果您在app.yaml 文件中指定入口点,则可以在requirements.txt 文件中包含gunicorn,但是您要安装的版本似乎与默认版本冲突。

    要解决这个问题,我建议您删除 requirements.txt 文件中的 gunicorn 依赖项和 app.yaml 中的入口点,并创建一个如下所示的 main.py 文件:

    from thisapp.wsgi import application
    
    app = application
    

    这样它会回到上面解释的默认行为并且应该可以正常工作。官方sample code也是这样实现的。

    【讨论】:

    • 非常有趣!是的,我想版本有问题。但是我删除了它们并且它起作用了。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2023-03-25
    • 2019-07-10
    • 1970-01-01
    • 1970-01-01
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 2019-10-31
    相关资源
    最近更新 更多