【问题标题】:/bin/sh: 1: exec: gunicorn: not found/bin/sh: 1: exec: gunicorn: 未找到
【发布时间】: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。 它们都可以在具有相同包的同一目录中的本地环境中完全正常工作。

我参考了这些问题thisthis 并尝试了答案,但没有任何效果。

【问题讨论】:

  • 您可以尝试使用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


【解决方案1】:

GAE 应用引擎需要与 app.yaml 位于同一目录的 requirements.txt 文件。

我的 requirements.txt 文件在一个子文件夹中,这就是为什么 google app engine 无法安装 gunicorn。 我在本地安装需求并在部署时传递已安装的需求,但似乎不需要在本地安装它们(除了在本地服务器上测试更改)。

【讨论】:

    猜你喜欢
    • 2018-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-18
    相关资源
    最近更新 更多