我有一个带有 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']
如果有人有任何解决方案或建议,我将不胜感激,因为我已经在 Internet 上调查了几乎所有相同的问题。
谢谢,
詹姆斯
最佳答案
默认情况下,App Engine 在应用程序目录的根目录中查找一个 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 .
关于django - Google App Engine Standard 找不到/执行 Gunicorn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56692369/