Reputation: 29
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.
Upvotes: 1
Views: 1875
Reputation: 114805
Another thing that can cause this error is if the gunicorn.conf.py
file is missing.
Upvotes: 0
Reputation: 21580
If you want to use gunicorn as your HTTP server, you need to tell it where your WSGI app is located. This is likely an app
variable in your main.py
file, so you can use:
entrypoint: gunicorn -b :$PORT -w 1 main:app
Upvotes: 2
Reputation: 29
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.
Upvotes: 0