Skip to content

Commit

Permalink
feat: add --debug to silverback run and silverback worker
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed May 31, 2024
1 parent 0274d16 commit 2023c8e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ async def run_worker(broker: AsyncBroker, worker_count=2, shutdown_timeout=90):
callback=_recorder_callback,
)
@click.option("-x", "--max-exceptions", type=int, default=3)
@click.option("--debug", is_flag=True, default=False)
@click.argument("path")
def run(cli_ctx, account, runner_class, recorder, max_exceptions, path):
def run(cli_ctx, account, runner_class, recorder, max_exceptions, debug, path):
if not runner_class:
# NOTE: Automatically select runner class
if cli_ctx.provider.ws_uri:
Expand All @@ -124,7 +125,7 @@ def run(cli_ctx, account, runner_class, recorder, max_exceptions, path):

app = import_from_string(path)
runner = runner_class(app, recorder=recorder, max_exceptions=max_exceptions)
asyncio.run(runner.run())
asyncio.run(runner.run(), debug=debug)


@cli.command(cls=ConnectedProviderCommand, help="Run Silverback application task workers")
Expand All @@ -138,7 +139,11 @@ def run(cli_ctx, account, runner_class, recorder, max_exceptions, path):
@click.option("-w", "--workers", type=int, default=2)
@click.option("-x", "--max-exceptions", type=int, default=3)
@click.option("-s", "--shutdown_timeout", type=int, default=90)
@click.option("--debug", is_flag=True, default=False)
@click.argument("path")
def worker(cli_ctx, account, workers, max_exceptions, shutdown_timeout, path):
def worker(cli_ctx, account, workers, max_exceptions, shutdown_timeout, debug, path):
app = import_from_string(path)
asyncio.run(run_worker(app.broker, worker_count=workers, shutdown_timeout=shutdown_timeout))
asyncio.run(
run_worker(app.broker, worker_count=workers, shutdown_timeout=shutdown_timeout),
debug=debug,
)

0 comments on commit 2023c8e

Please sign in to comment.