diff --git a/cratedb_toolkit/util/service.py b/cratedb_toolkit/util/service.py index a26c70b4..d2dc4440 100644 --- a/cratedb_toolkit/util/service.py +++ b/cratedb_toolkit/util/service.py @@ -15,7 +15,8 @@ def start_service(app: str, listen_address: t.Union[str, None] = None, reload: b if listen_address is None: listen_address = "127.0.0.1:4242" - host, port = listen_address.split(":") + host, _, port = listen_address.partition(":") + port = port or "0" port_int = int(port) logger.info(f"Starting HTTP web service on http://{listen_address}") diff --git a/cratedb_toolkit/wtf/http.py b/cratedb_toolkit/wtf/http.py index f2a73011..57d7a15a 100644 --- a/cratedb_toolkit/wtf/http.py +++ b/cratedb_toolkit/wtf/http.py @@ -38,4 +38,4 @@ def info(category: str, adapter: t.Annotated[DatabaseAdapter, Depends(database_a def start(listen_address: t.Union[str, None] = None, reload: bool = False): # pragma: no cover - start_service(app="cratedb_toolkit.wtf.http:app") + start_service(app="cratedb_toolkit.wtf.http:app", listen_address=listen_address, reload=reload) diff --git a/doc/wtf/index.md b/doc/wtf/index.md index 6113ac3a..2ef02429 100644 --- a/doc/wtf/index.md +++ b/doc/wtf/index.md @@ -51,7 +51,7 @@ Install. pip install --upgrade 'cratedb-toolkit[service]' ``` -Expose collected status information. +Expose collected status information. ```shell cratedb-wtf --debug serve --reload ``` @@ -60,6 +60,17 @@ Consume collected status information via HTTP. http http://127.0.0.1:4242/info/all ``` +Make the service listen on a specific address. +```shell +ctk wtf serve --listen 0.0.0.0:8042 +``` + +:::{note} +The `--reload` option is suitable for development scenarios where you intend +to have the changes to the code become available while editing, in near +real-time. +::: + ```{toctree} :maxdepth: 1