I am trying to deploy my app using Google App Engine. I have edited app.yaml to reflect the flexible environment and also gave all the app information. Below is the app.yaml file.
runtime: python env: flex entrypoint: gunicorn -b :$PORT main:app runtime_config: python_version: 3
Once the deployment is in progress, I am getting the following error
[2018-08-24 06:57:14 +0000] [1] [INFO] Starting gunicorn 19.7.1 [2018-08-24 06:57:14 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2018-08-24 06:57:14 +0000] [1] [INFO] Using worker: sync [2018-08-24 06:57:14 +0000] [7] [INFO] Booting worker with pid: 7 App Deployed Failed to find application: 'main' [2018-08-24 06:57:14 +0000] [7] [INFO] Worker exiting (pid: 7) [2018-08-24 06:57:14 +0000] [1] [INFO] Shutting down: Master [2018-08-24 06:57:14 +0000] [1] [INFO] Reason: App failed to load.
Please note that App Deployed is the line in my print statement. It is getting executed. But the deployment is getting failed
Thank you in advance
Advertisement
Answer
In your app.yaml
, you’re starting gunicorn with gunicorn -b :$PORT main:app
. This tells it to look for the object app
in the file main.py
The error you’re getting comes from gunicorn and occurs when you have a main.py
file, but it does not have an app
object in it.
You probably want to set up a Flask app as follows:
from flask import Flask app = Flask(__name__)
See a full example app here: https://cloud.google.com/appengine/docs/flexible/python/quickstart#hello_world_code_review