【问题标题】:GAE ERROR :- /bin/sh: 1: exec: gunicorn: not foundGAE 错误 :- /bin/sh: 1: exec: gunicorn: not found
【发布时间】:2018-06-06 02:02:24
【问题描述】:

我尝试使用他们的试用版在 GAE 上部署我的应用。到目前为止,我成功地使用 python 3.6 创建了一个带有自定义设置的 app.yaml,用于灵活的环境。

但是,在部署应用程序时,应用程序构建成功,但是,我不断收到以下错误

更新服务 [默认](这可能需要几分钟)...失败。 错误:(gcloud.app.deploy)错误响应:[9] 应用程序启动错误: /bin/sh: 1: exec: gunicorn: not found

以下是我项目中文件的文件夹层次结构:

按照 app.yaml 的代码

env: flex
runtime: custom
api_version: 1
entrypoint: gunicorn -b :$PORT main:app
runtime_config:
    python_version: 3.6

#handlers:
#- url: /SmsResponse
#  script: Twilio_Routing.RecivedSms
#
#- url: /CallResponse
#  script: Twilio_Routing.ReceivedCall

我肯定错过了一些东西,在这里我非常感谢一些帮助。 Link to git repo

requirements.txt

Flask==0.10.1
gunicorn==19.3.0
twilio==6.8.4

Docker 文件

FROM gcr.io/google-appengine/python
LABEL python_version=python3.6
RUN virtualenv --no-download /env -p python3.6

# Set virtualenv environment variables. This is equivalent to running
# source /env/bin/activate
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
ADD requirements.txt requirements.txt
RUN pip install -r requirements.txt

ADD . /app/

#CMD gunicorn -b :$PORT main:app
ENTRYPOINT [ "python", "Twilio_Routing.py" ]

附:在对 requirements.txt 进行更改后,我收到错误 502 Bad Gateway。

显示服务已成功执行的日志。

017-12-25 01:29:03 default[20171224t212610]   * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
2017-12-25 01:29:03 default[20171224t212610]   * Restarting with stat
2017-12-25 01:29:03 default[20171224t212610]   * Debugger is active!
2017-12-25 01:29:03 default[20171224t212610]   * Debugger PIN: 134-103-452
2017-12-25 01:29:17 default[20171224t212610]   * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
2017-12-25 01:29:17 default[20171224t212610]   * Restarting with stat
2017-12-25 01:29:17 default[20171224t212610]   * Debugger is active!
2017-12-25 01:29:17 default[20171224t212610]   * Debugger PIN: 134-103-452

有人可以在 git 中查看我的代码并告诉我这里缺少什么吗?

【问题讨论】:

  • 请您的Dockerfile 和您的requirements.txt
  • 请编辑您的问题并将文件内容添加为(代码格式)文本。
  • 按照建议进行的更改,我相信我错过了在 dockerfile 中添加 requirements.txt 文件,但我想弄清楚我应该把它放在哪里。
  • 我的问题是我拼错了 requirements.txt 文件

标签: python git api google-app-engine flask


【解决方案1】:

对我来说,错误就像确保 gunicorn 在 requirements.txt 中一样简单

Flask==1.0.2
gunicorn==19.9.0

注意:

我看到 OP 添加了这个标志;这是为了帮助其他可能遇到exec: gunicorn: not found

【讨论】:

    【解决方案2】:

    做了一些改动,我就可以在 docker 中运行你的应用了。

    1. Twilio_Routing.py 中,将 host 更改为在 0.0.0.0 而不是 127.0.0.1 上进行监听。这对于使服务器在外部也可用。
    2. 由于您的app.yaml 已配置,您无需按照Google App Engine 的要求自定义您的Dockerfile。将其保留为您自己的自定义。这是我使用的:

      #Python's Alpine Base Image
      FROM python:3.6-alpine3.6
      
      #Installing all python modules specified
      ADD requirements.txt requirements.txt
      RUN pip install -r requirements.txt
      
      #Copy App Contents
      ADD . /app
      WORKDIR /app
      
      #Start Flask Server
      CMD [ "python","Twilio_Routing.py"]
      #Expose server port
      EXPOSE 8080
      

    【讨论】:

    • 让我试一试。谢谢
    【解决方案3】:

    考虑到GoogleCloudPlatform/python-runtime 页面中显示的示例,请考虑将 CMD 行从以下位置更改:

    CMD exec gunicorn -b :$PORT main:app
    

    收件人:

    CMD gunicorn -b :$PORT main:app
    

    我只看到exec used here 的基础图像是python,而不是gcr.io/google-appengine/python

    【讨论】:

    • 我通过您的回答意识到我错过了在我的 dockerfile 中添加 requirements.txt ,我最终做到了。后来,它给了我一个关于no module name: main的错误,所以我将CMD命令替换为ENTRYPOINT命令,并成功部署。但是,当我尝试访问 my page 时,它给了我错误 502 Bad Gateway。我又有点卡住了。我在这里想念什么。我已根据我的最新更改更新了问题中的 dockerfile。
    • @AfsanAbdulaliGujarati 您是否检查了容器内的日志(不仅仅是 docker 日志)?
    • 如果你把它 app.py 你的应用程序而不是 main 呢?
    猜你喜欢
    • 2019-09-11
    • 1970-01-01
    • 2015-12-18
    • 2020-07-28
    • 2021-03-26
    • 1970-01-01
    • 2020-01-28
    • 1970-01-01
    • 2020-08-11
    相关资源
    最近更新 更多