Smacking my head against a desk trying to get this one to work. I'm trying to deploy a simple Flask app on gunicorn through Google App Engine. When visiting the app, I'm getting Error 500, with "gunicorn: error: No application module specified." in the logs.
My layout is roughly:
Main_Directory/
|-MyApp/
| |-__init__.py <- Containing majority of code
| |-templates/
| |-static/
|-app.yaml
|-main.py
|-requirements.txt
main.py
simply imports the app from MyApp
and instantiates a new instance called "app".
requirements.txt
has all dependencies, including gunicorn.
app.yaml is exactly as follows:
runtime: python37
instance_class: F1
default_expiration: "4d 12h"
entrypoint: gunicorn -b :$PORT -w 1
env_variables:
BUCKET_NAME: "bucket_name"
handlers:
- url: /.*
script: auto
I tried creating another app.yaml within the MyApp
folder and adding service: "default" but that didn't help. I'm pretty much out of ideas here. I'm fairly certain the issue is because the main app code is defined in MyApp
, rather than directly under the Main_directory
. I appreciate the easy solution would be to bring everything from the MyApp
folder up a level but I'm hesitating to do this as it will mess with my Git. I thought creating main.py and directly instantiating MyApp/__init__.py
would do the trick, but doesn't quite seem to.
Any and all ideas appreciated.
As is often the case, after reaching my limit and raising a question, I found an answer...
I removed the entrypoint from app.yaml
and removed gunicorn from requirements.txt
. On redeploying the app, it now works.
I don't feel like this is a fix, so much as a workaround. I'm still not sure why it didn't work before. There must be better solutions which maintain gunicorn as a requirement. I expect it was the yaml that was wrong.