CLI¶
The taskq console entry point (Typer).
cli ¶
taskq CLI entry point.
The CLI is intentionally thin today — only the commands needed to bootstrap a database. Worker and client commands will be added as those subsystems land.
Usage::
taskq migrate status
taskq migrate up [--phase pre|post] [--target VERSION] [--max-steps N]
app
module-attribute
¶
app = typer.Typer(
name="taskq",
no_args_is_help=True,
help="TaskQ — async Postgres-backed background jobs.",
)
migrate_app
module-attribute
¶
health_app
module-attribute
¶
workgroup_app
module-attribute
¶
workgroup_app = typer.Typer(
no_args_is_help=True,
help="Manage a multi-worker process group (supervisor).",
)
worker ¶
worker(
actors: str = typer.Option(
...,
"--actors",
help="Module:attr reference to the actor registry (e.g. myapp.actors:registry). Resolves at startup to a Mapping[str, ActorRef] or Iterable[ActorRef].",
),
force_update_actor_config: bool = typer.Option(
False,
"--force-update-actor-config",
help="Allow sync_actor_config to overwrite stored actor_config rows that differ from the registered values. Use for one deploy to deliberately change a stored max_concurrent / queue / metadata, then unset. Equivalent to env var TASKQ_FORCE_UPDATE_ACTOR_CONFIG=true.",
),
queues: list[str] | None = typer.Option(
None,
"--queues",
help="Comma-separated list of queue names to consume from. Overrides TASKQ_QUEUES.",
),
max_concurrency: int | None = typer.Option(
None,
"--max-concurrency",
help="Upper bound on concurrent jobs. Overrides TASKQ_MAX_CONCURRENCY.",
),
poll_interval: float | None = typer.Option(
None,
"--poll-interval",
help="Producer loop fallback polling cadence in seconds. Overrides TASKQ_POLL_INTERVAL.",
),
worker_group: str | None = typer.Option(
None,
"--worker-group",
help="Consumer group name for observability spans. Overrides TASKQ_WORKER_GROUP.",
),
worker_label: str | None = typer.Option(
None,
"--worker-label",
help="Human-readable label stored in the workers table for correlation with workgroup supervisors and external monitoring.",
),
workgroup_instance: str | None = typer.Option(
None,
"--workgroup-instance",
help="UUIDv7 identifying the workgroup orchestrator that launched this worker. Used for cross-process correlation and health checking.",
),
health_socket_path: str | None = typer.Option(
None,
"--health-socket-path",
help="Unix socket path for the health server. Overrides TASKQ_HEALTH_SOCKET_PATH. Use unique paths when running multiple workers on the same host.",
),
) -> None
Start a TaskQ worker consuming from the given actor registry.
Source code in src/taskq/cli.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
dev_watch ¶
dev_watch(
actors: Annotated[
str,
Argument(help="Import path: dotted.module:attr"),
],
watch: Annotated[
list[str] | None,
Option(
--watch,
help="Path to watch (repeatable). Default: cwd.",
),
] = None,
grace_period: Annotated[
int,
Option(
--grace - period,
min=0,
help="Seconds before SIGKILL. Default: 5.",
),
] = 5,
) -> None
Run a worker in dev mode with auto-reload on file changes.
Source code in src/taskq/cli.py
migrate_status ¶
migrate_up ¶
migrate_up(
phase: Phase | None = typer.Option(
None, "--phase", help="Restrict to 'pre' or 'post'."
),
target: str | None = typer.Option(
None,
"--target",
help="Stop after this version (inclusive). E.g. 01.00.00_01",
),
max_steps: int | None = typer.Option(
None, "--max-steps", help="Cap number of applies."
),
) -> None
Apply pending migrations.
Source code in src/taskq/cli.py
health_live ¶
health_ready ¶
health_metrics ¶
ui_serve ¶
ui_serve(
pg_dsn: str | None = typer.Option(
None,
"--pg-dsn",
help="Postgres DSN. Falls back to TASKQ_PG_DSN via dotenvmodel.",
),
schema: str | None = typer.Option(
None,
"--schema",
help="Postgres schema name. Falls back to TASKQ_SCHEMA_NAME via dotenvmodel.",
),
redis_url: str | None = typer.Option(
None,
"--redis-url",
help="Redis URL for real-time mode. Falls back to TASKQ_REDIS_URL via dotenvmodel.",
),
host: str | None = typer.Option(
None,
"--host",
help="Bind address. Falls back to TASKQ_ADMIN_HOST via dotenvmodel.",
),
port: int | None = typer.Option(
None,
"--port",
help="Bind port. Falls back to TASKQ_ADMIN_PORT via dotenvmodel.",
),
run_migrate: bool = typer.Option(
False,
"--migrate",
help="Apply pending migrations before starting. Aborts startup if migrations fail.",
),
) -> None
Start the admin UI server on the given host:port.
Source code in src/taskq/cli.py
main ¶
workgroup_start ¶
workgroup_start(
config: Annotated[
Path,
Argument(
help="Path to the workgroup TOML configuration file."
),
],
) -> None
Start a workgroup supervisor that manages multiple worker processes.
The supervisor spawns one taskq worker subprocess per [[workers]]
entry in the config file, monitors their health, restarts them on crash,
and propagates shutdown signals.
Source code in src/taskq/cli.py
workgroup_validate ¶
workgroup_validate(
config: Annotated[
Path,
Argument(
help="Path to the workgroup TOML configuration file."
),
],
) -> None
Validate a workgroup TOML config without starting any workers.