【发布时间】:2021-03-26 19:58:42
【问题描述】:
我正在尝试在谷歌云应用引擎上部署一个简单的 django 应用。应用程序具有基本的 wsgi 和 asgi 服务器,其中 wsgi 服务于 HTTPS 请求,而 asgi 服务于 websocket 请求。 我正在按照谷歌应用引擎教程来部署应用程序,并且它已成功构建和部署。但是,在已部署的工作空间中找不到已安装的软件包。
这些是我正在遵循的步骤
gcloud init
virtualenv myenv
source activate myenv/bin/activate
pip install -r requirements.txt
gcloud app deploy
requirements.txt 确实有 gunicorn 和 daphne,它们也已安装。
这是我在浏览器上打开已部署的应用程序时遇到的错误。
2020-12-15 20:48:25 my-service[20201216t014451] /bin/sh: 1: exec: gunicorn: not found
这就是我的 app.yaml 文件的样子
runtime: python38
service: my-service
instance_class: F2
entrypoint: gunicorn -b :$PORT main:app
handlers:
- url: /.*
script: auto
secure: always
inbound_services:
- warmup
automatic_scaling:
min_instances: 1
min_idle_instances: 1
max_instances: 2
max_idle_instances: 1
我也尝试过在入口点传递确切路径,即 entrypoint: gunicorn -b :$PORT main:app 但得到了同样的错误
我在我的 virtualenv 中调用 gcloud app deploy,但是当它被部署时,它无法读取已安装的软件包,即 daphne 和 gunicorn。 它们都可以在具有相同包的同一目录中的本地环境中完全正常工作。
【问题讨论】:
-
您可以尝试使用
gcloud beta app deploy --no-cache进行部署吗?另外请查看following section of the public docs,以了解 App Engine Standard 如何管理gunicorn和应用程序启动。如果上述方法失败,您可以尝试使用App Engine Flex 进行测试。 -
嘿。谢谢。我错过了诀窍。我曾经使用 pip 安装依赖项,并在环境中使用已安装的依赖项进行部署。我的 requirements.txt 文件位于子文件夹中。但是,谷歌应用引擎只需要基本文件夹中的 requirements.txt 文件,它会在构建自身时安装依赖项(沿着 gunicorn )。我的问题现在已经解决了。
-
总是乐于提供帮助。我会为社区和跟踪目的发布答案。
标签: google-app-engine google-cloud-platform google-compute-engine gunicorn daphne