GAE ERROR :- /bin/sh: 1: exec: gunicorn: not found

别等时光非礼了梦想. 提交于 2021-02-07 05:37:05

问题


I trying to deploy my app on GAE using their trial version. I was so far successful in creating an app.yaml with a custom settings for flexible environment with python 3.6.

However, while deploying the app, the app builds successfully, however, I keep getting the following error

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

Following is the folder hierarchy of files in my project:

Following the code for 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

I am surely missing out on something and I would really appreciate some help here. Link to git repo

requirements.txt

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

DockerFile

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. After the changes for the requirements.txt, I am getting error 502 Bad Gateway.

Logs showing that the service was executed successfully.

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

Can someone look at my code in git and tell me what is it that I am missing here?


回答1:


A few changes and I was able to run your app in docker.

  1. In Twilio_Routing.py , change host to listen on 0.0.0.0 instead of 127.0.0.1.This is needed to to have the server available externally as well.
  2. Since your app.yaml is already configured, you don't need to customize your Dockerfile as Google App Engine requires. Keep it as your own custom one.Here's what I used:

    #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
    



回答2:


for me the error was as simple as making sure gunicorn was in requirements.txt

Flask==1.0.2
gunicorn==19.9.0

Note:

I see the OP had added this flag; this is to help others that may be running into exec: gunicorn: not found




回答3:


Considering the example shown in the GoogleCloudPlatform/python-runtime page, consider changing your CMD line from:

CMD exec gunicorn -b :$PORT main:app

To:

CMD gunicorn -b :$PORT main:app

I see exec used here only when the base image is the python one, not gcr.io/google-appengine/python.



来源:https://stackoverflow.com/questions/47958066/gae-error-bin-sh-1-exec-gunicorn-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!