--uds option for binding to Unix domain socket, closes #1388

This commit is contained in:
Simon Willison 2021-07-10 16:37:30 -07:00
commit 180c7a5328
6 changed files with 65 additions and 2 deletions

View file

@ -333,6 +333,10 @@ def uninstall(packages, yes):
type=click.IntRange(0, 65535),
help="Port for server, defaults to 8001. Use -p 0 to automatically assign an available port.",
)
@click.option(
"--uds",
help="Bind to a Unix domain socket",
)
@click.option(
"--reload",
is_flag=True,
@ -428,6 +432,7 @@ def serve(
immutable,
host,
port,
uds,
reload,
cors,
sqlite_extensions,
@ -569,6 +574,8 @@ def serve(
uvicorn_kwargs = dict(
host=host, port=port, log_level="info", lifespan="on", workers=1
)
if uds:
uvicorn_kwargs["uds"] = uds
if ssl_keyfile:
uvicorn_kwargs["ssl_keyfile"] = ssl_keyfile
if ssl_certfile: