atlanticwave-sdx / sdx-controller

Central Controller for AtlanticWave SDX.
https://www.atlanticwave-sdx.net
MIT License
1 stars 3 forks source link

Make `docker compose up` work on the testbed #217

Closed sajith closed 6 months ago

sajith commented 6 months ago

Some issues were surfaced when testing on testbed:

It appears that we're only a WSGI app, not an ASGI app. We need to tell uvicorn this fact, or it will error out when handling a request:

sdx-controller-1  | ERROR:    Exception in ASGI application
sdx-controller-1  | Traceback (most recent call last):
sdx-controller-1  |   File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 404, in run_asgi
sdx-controller-1  |     result = await app(  # type: ignore[func-returns-value]
sdx-controller-1  |   File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
sdx-controller-1  |     return await self.app(scope, receive, send)
sdx-controller-1  |   File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/asgi2.py", line 16, in __call__
sdx-controller-1  |     instance = self.app(scope)
sdx-controller-1  | TypeError: __call__() missing 1 required positional argument: 'start_response'

There are two ways to handle this. We can either pass an --interface wsgi argument to uvicorn, or use the asgiref.WsgiToAsgi adapter (as described here). I like the latter option, because that way we can switch to other ASGI servers also, if we need to.

The second problem is that we need to bind to 0.0.0.0:8080 (and not localhost:8080) so that the port can be exposed to the world.