Closed 4n1qz5skwv closed 1 week ago
If this library added to unit frameworks it will be at top of the list (alphabetical order) 😃
I'm not too familiar with exactly how WSGI works, but our docs suggest either deploying with a proxy over unix socket (https://docs.aiohttp.org/en/stable/deployment.html#nginx-supervisord) or with Gunicorn (https://docs.aiohttp.org/en/stable/deployment.html#nginx-gunicorn).
I think the gunicorn worker creates a WSGI interface (atleast I see references to wsgi in the code: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/worker.py), so maybe you just need to make use of Gunicorn in order to give Unit a WSGI environment to work with?
If you figure it out, we can consider taking any changes or updating the docs if it's not obvious.
To be clear though, the web.Application
object does not handle running the program, so your example will definitely not work, you need some kind of runner, e.g. a regular application run would use: https://docs.aiohttp.org/en/stable/web_reference.html#aiohttp.web.run_app or https://docs.aiohttp.org/en/stable/web_advanced.html#application-runners).
WSGI
ASGI ?
WSGI
I tried with protocol "asgi" (https://unit.nginx.org/configuration/#python) .
so your example will definitely not work
I know. But all the popular lib already supported and listed there. I don't know how the unit works actually. It just works with all the similar libraries. So i thought may be it support aiohttp too.
If you can please consider adding support for unit 🙏
@Dreamsorcerer
WSGI
ASGI ?
Seem to be similar, Unit says it supports both, and I suspect you can get Gunicorn to do either too.
I know. But all the popular lib already supported and listed there. I don't know how the unit works actually. It just works with all the similar libraries. So i thought may be it support aiohttp too.
Docs say it just uses WSGI or ASGI (https://unit.nginx.org/#supported-app-languages), so I doubt we need Unit-specific config. But, other libraries often use these as the default method of running their applications, whereas we default to running on a socket. So, you'll just need play around to figure it out. Again, Gunicorn may provide what you need, so I'd start looking there.
@4n1qz5skwv aiohttp doesn't support ASGI, so you would not be able to run it as described unless you provide your own wrapper around.
I'm going to close this as a duplicate of #8473, as it doesn't look like there's any other approach that Unit will work other than ASGI.
Describe the bug
Trying use "aiohttp" with "nginx unit"
aiohttp is not listed in https://unit.nginx.org/howto/#frameworks
So, tried to use basic ASGI approach. Not working.
To Reproduce
app = web.Application()
Expected behavior
Expected behavior:
404: Not Found
Actual behavior:
Error 503.
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
ubuntu 22.04
Related component
Server
Additional context
Please add support for unit.
https://unit.nginx.org/ https://unit.nginx.org/howto/#frameworks
If possible please add this library to unit frameworks list with a demo. It will be very very helpful for us to get started.
Thank you for this awesome lib.
Code of Conduct