Google App Engine Python: Error in yaml config file when deploying

本秂侑毒 提交于 2020-01-22 20:10:27

问题


I'm using Google App Engine, Python37 environment. I got an error message when trying to deploy a microservice today:
I run the command:

gcloud app deploy app.yaml

Got the error:

...
File upload done.
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: script field for handler '/.*' 
must be set to 'auto' for runtime python37.
PS C:\path_to_app> gcloud app deploy app.yaml
...

My app.yaml is:

service: service_name
runtime: python37

handlers:
- url: /.*
script: main.py

It looks exactly the same from other microservices that I have deployed recently, just the service name is different.
I tried to re-deploy a services that is already running and got same error message.
So I double check app.yaml reference document: https://cloud.google.com/appengine/docs/standard/python3/config/appref
But I couldn't find out what is wrong neither why the same yaml file that had worked before doesn't work anymore.

Does anyone know what can be wrong or maybe what can be changed on Google App Engine in the last days?

Thanks in advance.


回答1:


As per the AppEngine documentation for Python 3.7,

The only accepted value for the script element is auto

Below is a sample entry from the documentation:

handlers:
- url: /images
  static_dir: static/images

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto



回答2:


I got this error when deploying a flask app with a blueprint structure. The solution is to have main.py file in the same directory as app.yaml file. In the main.py file, import the app object e.g from app import app (here the first 'app' is the folder containing an init file where the flask app instance is created). After doing this, setting script to auto should work fine.



来源:https://stackoverflow.com/questions/53117774/google-app-engine-python-error-in-yaml-config-file-when-deploying

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