google-app-engine - /bin/sh: 1: exec: gunicorn: 未找到
问题描述
我正在尝试在谷歌云应用引擎上部署一个简单的 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
我也尝试过在入口点传递确切的路径,即入口点:gunicorn -b :$PORT main:app但得到了同样的错误
我在我的 virtualenv 中调用gcloud app deploy但是当它被部署时,它无法读取已安装的包,即 daphne 和 gunicorn。它们都在具有相同包的同一目录中的本地环境中工作得很好。
解决方案
GAE 应用引擎需要与 app.yaml 位于同一目录中的 requirements.txt 文件。
我的 requirements.txt 文件位于子文件夹中,这就是谷歌应用引擎无法安装 gunicorn 的原因。我在本地安装要求并在部署时传递已安装的要求,但似乎不需要在本地安装它们(除了在本地服务器上测试更改)。
推荐阅读
- java - Apache Beam DataflowRunner 无法写入 AWS S3
- laravel - Laravel Livewire key() 期望参数 1 是数组,给定整数 | 嵌套组件 | 在循环中加载组件
- scala - 如何在 sparknlp 中为文本文件使用注释器
- android - 如何根据按钮单击android更新适配器列表
- android-studio - 为 obj 和 gltf 文件导入 Sceneform 资源时出错
- docker - 我可以在一台计算机上使用多个 docker 容器作为 Kubernetes 工作节点吗?
- android - 图像编码和解码。base64 字符串图像
- android - 谷歌拟合数据能持续多久?
- autosar - 如何验证 AutoSar TSYNC?
- sql-server - 编写一个嵌套的 IIF 函数