簡體   English   中英

GAE 錯誤 :- /bin/sh: 1: exec: gunicorn: not found

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

我嘗試使用他們的試用版在 GAE 上部署我的應用程序。 到目前為止,我成功地使用 python 3.6 創建了一個帶有自定義設置的 app.yaml,用於靈活的環境。

但是,在部署應用程序時,應用程序構建成功,但是,我不斷收到以下錯誤

更新服務 [默認](這可能需要幾分鍾)...失敗。 錯誤:(gcloud.app.deploy)錯誤響應:[9]應用程序啟動錯誤:/bin/sh:1:exec:gunicorn:未找到

以下是我項目中文件的文件夾層次結構:

在此處輸入圖像描述

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

我肯定錯過了一些東西,我非常感謝這里的一些幫助。 鏈接到 git 倉庫

要求.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" ]

PS 在對 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 中查看我的代碼並告訴我我在這里缺少什么嗎?

一些更改,我能夠在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 

對我來說,錯誤就像確保gunicorn在requirements.txt一樣簡單

Flask==1.0.2
gunicorn==19.9.0

注意:

我看到OP增加了這個標志; 這是為了幫助其他可能exec: gunicorn: not found

考慮到GoogleCloudPlatform/python-runtime頁面中顯示的示例,請考慮更改您的CMD行:

CMD exec gunicorn -b :$PORT main:app

至:

CMD gunicorn -b :$PORT main:app

我看到exec只在基本圖像是python ,而不是gcr.io/google-appengine/python

最近,當我嘗試運行我的 docker 映像時,我也遇到了這個錯誤。 /bin/sh: 1: gunicorn: 未找到

對我有用的簡單技巧

  1. 刪除容器和圖像
  2. 重新啟動泊塢窗引擎。
  3. 並嘗試使用以下命令 docker build -t <image_name>:<tag_name> 再次創建圖像。

並嘗試使用此命令運行。 docker run -p 5000:5000 -e PORT =5000 鏡像ID

它對我有用! 希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM