Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions chancy/cli/worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import secrets

import click
from click.core import ParameterSource

from chancy import Chancy, Worker
from chancy.cli import run_async_command
Expand Down Expand Up @@ -106,6 +107,19 @@ async def web_command(
f"No username or password was provided for the API, defaulting"
f" to 'admin' with a random password: {auth.users['admin']}"
)
else:
# Override API plugin settings only if CLI flags were explicitly provided
if ctx.get_parameter_source("host") != ParameterSource.DEFAULT:
api.host = host
if ctx.get_parameter_source("port") != ParameterSource.DEFAULT:
api.port = port
if ctx.get_parameter_source("debug") != ParameterSource.DEFAULT:
api.debug = debug
if (
ctx.get_parameter_source("allow_origin")
!= ParameterSource.DEFAULT
):
api.allow_origins = allow_origin

worker.manager.add("api", api.run(worker, chancy))
await worker.wait_for_shutdown()