Skip to content

Commit

Permalink
feat: Add LITESTAR_ prefix before WEB_CONCURRENCY env option (#3227)
Browse files Browse the repository at this point in the history
* feat: Add LITESTAR_ prefix for web concurrency env option

* Replace depacrated with versionchanged directive

* Change wc option description

* Remove depracation warning

---------

Co-authored-by: kedod <kedod>
  • Loading branch information
kedod committed Mar 27, 2024
1 parent e751d20 commit 250d89a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
65 changes: 34 additions & 31 deletions docs/usage/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,37 +103,40 @@ The ``run`` command executes a Litestar application using `uvicorn <https://www.
Options
~~~~~~~

+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| Flag | Environment variable | Description |
+===========================================+==============================================+==================================================================================+
| ``-r``\ , ``--reload`` | ``LITESTAR_RELOAD`` | Reload the application when files in its directory are changed |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``-R``\ , ``--reload-dir`` | ``LITESTAR_RELOAD_DIRS`` | Specify directories to watch for reload. |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``-I``\ , ``--reload-include`` | ``LITESTAR_RELOAD_INCLUDES`` | Specify glob patterns for files to include when watching for reload. |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``-E``\ , ``--reload-exclude`` | ``LITESTAR_RELOAD_EXCLUDES`` | Specify glob patterns for files to exclude when watching for reload. |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``-p``\ , ``--port`` | ``LITESTAR_PORT`` | Bind the server to this port [default: 8000] |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``--wc``\ , ``--web-concurrency`` | ``WEB_CONCURRENCY`` | The number of concurrent web workers to start [default: 1] |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``-H``\ , ``--host`` | ``LITESTAR_HOST`` | Bind the server to this host [default: 127.0.0.1] |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``--fd``\ , ``--file-descriptor`` | ``LITESTAR_FILE_DESCRIPTOR`` | Bind to a socket from this file descriptor. |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``--uds``\ , ``--unix-domain-socket`` | ``LITESTAR_UNIX_DOMAIN_SOCKET`` | Bind to a UNIX domain socket. |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``-d``\ , ``--debug`` | ``LITESTAR_DEBUG`` | Run the application in debug mode |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``--pdb``\ , ``--use_pdb`` | ``LITESTAR_PDB`` | Drop into the Python debugger when an exception occurs |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``--ssl-certfile`` | ``LITESTAR_SSL_CERT_PATH`` | Path to a SSL certificate file |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``--ssl-keyfile`` | ``LITESTAR_SSL_KEY_PATH`` | Path to the private key to the SSL certificate |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
| ``--create-self-signed-cert`` | ``LITESTAR_CREATE_SELF_SIGNED_CERT`` | If the SSL certificate and key are not found, generate a self-signed certificate |
+-------------------------------------------+----------------------------------------------+----------------------------------------------------------------------------------+
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| Flag | Environment variable | Description |
+===========================================+==============================================+============================================================================================+
| ``-r``\ , ``--reload`` | ``LITESTAR_RELOAD`` | Reload the application when files in its directory are changed |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``-R``\ , ``--reload-dir`` | ``LITESTAR_RELOAD_DIRS`` | Specify directories to watch for reload. |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``-I``\ , ``--reload-include`` | ``LITESTAR_RELOAD_INCLUDES`` | Specify glob patterns for files to include when watching for reload. |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``-E``\ , ``--reload-exclude`` | ``LITESTAR_RELOAD_EXCLUDES`` | Specify glob patterns for files to exclude when watching for reload. |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``-p``\ , ``--port`` | ``LITESTAR_PORT`` | Bind the server to this port [default: 8000] |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``--wc``\ , ``--web-concurrency`` | ``LITESTAR_WEB_CONCURRENCY`` | .. versionchanged:: 2.8 |
| | ``WEB_CONCURRENCY`` | ``LITESTAR_WEB_CONCURRENCY`` is supported and takes precedence over ``WEB_CONCURRENCY`` |
| | | |
| | | The number of concurrent web workers to start [default: 1] |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``-H``\ , ``--host`` | ``LITESTAR_HOST`` | Bind the server to this host [default: 127.0.0.1] |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``--fd``\ , ``--file-descriptor`` | ``LITESTAR_FILE_DESCRIPTOR`` | Bind to a socket from this file descriptor. |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``--uds``\ , ``--unix-domain-socket`` | ``LITESTAR_UNIX_DOMAIN_SOCKET`` | Bind to a UNIX domain socket. |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``-d``\ , ``--debug`` | ``LITESTAR_DEBUG`` | Run the application in debug mode |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``--pdb``\ , ``--use_pdb`` | ``LITESTAR_PDB`` | Drop into the Python debugger when an exception occurs |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``--ssl-certfile`` | ``LITESTAR_SSL_CERT_PATH`` | Path to a SSL certificate file |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``--ssl-keyfile`` | ``LITESTAR_SSL_KEY_PATH`` | Path to the private key to the SSL certificate |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+
| ``--create-self-signed-cert`` | ``LITESTAR_CREATE_SELF_SIGNED_CERT`` | If the SSL certificate and key are not found, generate a self-signed certificate |
+-------------------------------------------+----------------------------------------------+--------------------------------------------------------------------------------------------+

--reload-dir
++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion litestar/cli/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def info_command(app: Litestar) -> None:
type=click.IntRange(min=1, max=multiprocessing.cpu_count() + 1),
show_default=True,
default=1,
envvar="WEB_CONCURRENCY",
envvar=["LITESTAR_WEB_CONCURRENCY", "WEB_CONCURRENCY"],
)
@option("-H", "--host", help="Server under this host", default="127.0.0.1", show_default=True, envvar="LITESTAR_HOST")
@option(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_cli/test_core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_run_command(
if web_concurrency is None:
web_concurrency = 1
elif set_in_env:
monkeypatch.setenv("WEB_CONCURRENCY", str(web_concurrency))
monkeypatch.setenv("LITESTAR_WEB_CONCURRENCY", str(web_concurrency))
else:
args.extend(["--web-concurrency", str(web_concurrency)])

Expand Down Expand Up @@ -326,7 +326,7 @@ def test_run_command_with_app_factory(
),
(
("--wc", 2),
("WEB_CONCURRENCY", 4),
("LITESTAR_WEB_CONCURRENCY", 4),
"--workers=2",
),
(
Expand Down

0 comments on commit 250d89a

Please sign in to comment.