GAE错误:-/bin/sh:1:exec:gunicorn:未找到

2024-04-27 11:28:51 发布

您现在位置:Python中文网/ 问答频道 /正文

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

但是,在部署应用程序时,该应用程序会成功生成,但是,我一直收到以下错误

Updating service [default] (this may take several minutes)...failed. ERROR: (gcloud.app.deploy) Error Response: [9] Application startup error: /bin/sh: 1: exec: gunicorn: not found

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

enter image description here

遵循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

需求.txt

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

停靠文件

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" ]

p.S.更改requirements.txt之后,我得到错误502坏网关。

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

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中的代码并告诉我这里缺少什么吗?


Tags: toenvtxtapp应用程序defaultbinvirtualenv
3条回答

考虑到^{}页面中显示的示例,请考虑将您的命令行更改为:

CMD exec gunicorn -b :$PORT main:app

致:

CMD gunicorn -b :$PORT main:app

我只看到^{} used here当基图像是python时,而不是gcr.io/google-appengine/python

对我来说,错误很简单,只要确定gunicorn在requirements.txt

Flask==1.0.2
gunicorn==19.9.0

注意:

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

做了一些修改,我就可以在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
    

相关问题 更多 >