[PATCH] aurweb.spawn: Integrate FastAPI and nginx

Lukas Fleischer lfleischer at archlinux.org
Sun May 31 14:16:43 UTC 2020


Thanks a lot for the patch; two minor comments inline in addition to
what Filipe mentioned previously (I am fine with ^C instead of CTRL+C by
the way but don't care much either way).

On Sat, 30 May 2020 at 13:41:07, Frédéric Mangano-Tarumi wrote:
> aurweb.spawn used to launch only PHP\u2019s built-in server. Now it spawns a
> dummy FastAPI application too. Since both stacks spawn their own HTTP
> server, aurweb.spawn also spawns nginx as a reverse proxy to mount them
> under the same base URL, defined by aur_location in the configuration.
> ---
>  TESTING              |  3 +-
>  aurweb/asgi.py       |  8 +++++
>  aurweb/spawn.py      | 80 +++++++++++++++++++++++++++++++++++++-------
>  conf/config.defaults |  7 ++++
>  4 files changed, 85 insertions(+), 13 deletions(-)
>  create mode 100644 aurweb/asgi.py
> [...]
> diff --git a/aurweb/asgi.py b/aurweb/asgi.py
> new file mode 100644
> index 00000000..8d3deedc
> --- /dev/null
> +++ b/aurweb/asgi.py
> @@ -0,0 +1,8 @@
> +from fastapi import FastAPI
> +
> +app = FastAPI()
> +
> +
> + at app.get("/sso/")
> +async def hello():
> +    return {"message": "Hello from FastAPI!"}

I know that this is in preparation of the next step, SSO, but can we use
a separate path here, such as /hello/ or /test/? That would cause less
confusion to future readers of this patch (who may not have any context)
and would allow us to decouple the actual SSO patch series from this
patch more easily. For example, that series could start with a patch to
remove this test, and all followup patches would not mention this test
at all.

> diff --git a/conf/config.defaults b/conf/config.defaults
> index 86fe765c..ed495168 100644
> --- a/conf/config.defaults
> +++ b/conf/config.defaults
> @@ -41,9 +41,16 @@ cache = none
>  cache_pkginfo_ttl = 86400
>  memcache_servers = 127.0.0.1:11211
>  
> +[php]
> +; Address PHP should bind when spawned in development mode by aurweb.spawn.
> +bind_address = 127.0.0.1:8081
>  ; Directory containing aurweb's PHP code, required by aurweb.spawn.
>  ;htmldir = /path/to/web/html
>  
> +[fastapi]
> +; Address uvicorn should bind when spawned in development mode by aurweb.spawn.
> +bind_address = 127.0.0.1:8082
> +

Even if the dev-only options are indicated by comments, I am not sure
whether it's a good idea to mix production and development configuration
like this. Can we put them in a separate file or at least a separate
section without too much effort?

Best regards,
Lukas


More information about the aur-dev mailing list