Open fifthecho opened 7 years ago
It's worth mentioning that this is my first Sanic application, but it returns properly on localhost.
The tricky part I would imagine is how to handle the event loop. That is the same reason it was tricky to get Tornado working.
I'm working on this but having some basic difficulties as this is my first zappa deployment. The dependencies aren't being packaged, though I can't tell why. Is there a way to get more debug info regarding what is being packaged in the zip? It works to import the needed requirements in my virtual environment.
Furthermore the dependencies do exist in the correct location:
>>> import httptools
>>> httptools.__file__
'/Users/r0fls/Documents/code/foss/zappa/sanic-test/36/lib/python3.6/site-packages/httptools/__init__.py'
However I don't see any open issues about dependency packaging. Does it have to be an egg or wheel? 🤔 I see https://github.com/Miserlou/Zappa/issues/185#issuecomment-246439291 but it looks like @fifthecho has gotten farther than me...
@fifthecho would you be willing to post your entire code into a repo or upload, including the virtual environment, packages, etc...? I couldn't even seem to get to the point you're at.
https://github.com/fifthecho/zappa-sanic is a super basic app but exhibits the behaviors I've logged when I deploy it.
I think that Sanic isn't WSGI?
You may need this: https://github.com/ashleysommer/sanic-dispatcher
So
app = Sanic(__name__)
dispatcher = SanicDispatcherMiddlewareController(app)
Then myapp.dispatcher
as the app_function
in Zappa settings.
(Just a theory)
A viable theory. It may be a few days before I can test myself, but if others want to give it a shot and report back, please do.
So unfortunately, sanic_dispatcher
goes "the wrong way".
https://github.com/ashleysommer/sanic-dispatcher/issues/4
Gotta check out this gunicorn worker business... https://github.com/channelcat/sanic/blob/master/docs/sanic/deploying.md#running-via-gunicorn
Also some talk over on the Sanic side that seems relevant about Werkzeug and ...a WSGI adapter, that'd allow you to eg. deploy to zappa.
https://github.com/channelcat/sanic/issues/761#issuecomment-313146637
Now that Lambda and Zappa support Python 3.6, it's time to go fast!
Context
Using Python 3.6.1 build a simple Sanic app:
Deploy using
zappa deploy
Expected Behavior
When calling the deployed app, you should get a JSON response of
{"ping": "pong"}
Actual Behavior
Your Environment
zappa_settings.py
: