feat(cli): expose --workers on decnet api
Forwards straight to uvicorn's --workers. Default stays at 1 so the single-worker efficiency direction is preserved; raising it is available for threat-actor load scenarios where the honeypot needs to soak real attack traffic without queueing on one event loop.
This commit is contained in:
@@ -84,6 +84,7 @@ def api(
|
|||||||
host: str = typer.Option(DECNET_API_HOST, "--host", help="Host IP for the backend API"),
|
host: str = typer.Option(DECNET_API_HOST, "--host", help="Host IP for the backend API"),
|
||||||
log_file: str = typer.Option(DECNET_INGEST_LOG_FILE, "--log-file", help="Path to the DECNET log file to monitor"),
|
log_file: str = typer.Option(DECNET_INGEST_LOG_FILE, "--log-file", help="Path to the DECNET log file to monitor"),
|
||||||
daemon: bool = typer.Option(False, "--daemon", "-d", help="Detach to background as a daemon process"),
|
daemon: bool = typer.Option(False, "--daemon", "-d", help="Detach to background as a daemon process"),
|
||||||
|
workers: int = typer.Option(1, "--workers", "-w", min=1, help="Number of uvicorn worker processes"),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Run the DECNET API and Web Dashboard in standalone mode."""
|
"""Run the DECNET API and Web Dashboard in standalone mode."""
|
||||||
import subprocess # nosec B404
|
import subprocess # nosec B404
|
||||||
@@ -91,18 +92,17 @@ def api(
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
if daemon:
|
if daemon:
|
||||||
log.info("API daemonizing host=%s port=%d", host, port)
|
log.info("API daemonizing host=%s port=%d workers=%d", host, port, workers)
|
||||||
_daemonize()
|
_daemonize()
|
||||||
|
|
||||||
log.info("API command invoked host=%s port=%d", host, port)
|
log.info("API command invoked host=%s port=%d workers=%d", host, port, workers)
|
||||||
console.print(f"[green]Starting DECNET API on {host}:{port}...[/]")
|
console.print(f"[green]Starting DECNET API on {host}:{port} (workers={workers})...[/]")
|
||||||
_env: dict[str, str] = os.environ.copy()
|
_env: dict[str, str] = os.environ.copy()
|
||||||
_env["DECNET_INGEST_LOG_FILE"] = str(log_file)
|
_env["DECNET_INGEST_LOG_FILE"] = str(log_file)
|
||||||
|
_cmd = [sys.executable, "-m", "uvicorn", "decnet.web.api:app",
|
||||||
|
"--host", host, "--port", str(port), "--workers", str(workers)]
|
||||||
try:
|
try:
|
||||||
subprocess.run( # nosec B603 B404
|
subprocess.run(_cmd, env=_env) # nosec B603 B404
|
||||||
[sys.executable, "-m", "uvicorn", "decnet.web.api:app", "--host", host, "--port", str(port)],
|
|
||||||
env=_env
|
|
||||||
)
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
except (FileNotFoundError, subprocess.SubprocessError):
|
except (FileNotFoundError, subprocess.SubprocessError):
|
||||||
|
|||||||
Reference in New Issue
Block a user