Tom Han
05/06/2026, 6:17 PM--run-onceMarvin
05/06/2026, 6:17 PMMarvin
05/06/2026, 6:18 PM--run-once.
Example:
bash
prefect worker start --pool my-pool --type process --run-once
That tells the worker to:
1. poll for work once
2. start any flow runs it picks up
3. wait for those active runs to finish
4. exit
So it’s effectively “run one polling cycle, then shut down once the work you claimed is done.”
A couple notes:
- It is not “stop after the currently running flow on an already-running worker”
- It is “start this worker in one-shot mode”
- This works for process workers too
CLI help confirms the option exists:
prefect worker start --help
Relevant docs:
- Workers
- Worker CLI reference
If what you mean is slightly different — e.g. signal an already-running worker to drain and exit after its current flow run — that’s a different behavior, and Prefect doesn’t expose a simple “drain after current job” flag on a live worker the same way some queue systems do. In that case I can suggest a few patterns depending on whether you’re using process, docker, or k8s workers.Tom Han
05/06/2026, 6:19 PMMarvin
05/06/2026, 6:19 PMNate
05/06/2026, 6:20 PMNate
05/06/2026, 6:20 PMNate
05/06/2026, 6:21 PMTom Han
05/06/2026, 6:22 PMMarvin
05/06/2026, 6:22 PM--run-once
So if your goal is exactly:
“don’t take any more work, but let the current run finish, then exit”Prefect workers don’t currently expose that as a first-class drain mode. A practical workaround for a single worker is: 1. make sure it won’t claim new work - pause the work pool, or - restrict/remove the queue it polls, or - otherwise isolate it from new assignments 2. wait until its current flow run completes 3. terminate the worker process If you want, I can help you pick the safest approach based on how this worker is targeted: - dedicated work pool? - specific work queue? - multiple workers sharing the same pool? - process launched via systemd / docker / kubernetes / plain shell? Relevant docs: - Workers - Worker CLI
Tom Han
05/06/2026, 6:23 PMNate
05/06/2026, 6:28 PMNate
05/06/2026, 6:28 PMTom Han
05/06/2026, 6:38 PMTom Han
05/06/2026, 6:40 PM# Entrypoint: starts Prefect worker; names it after the pod by default
ENTRYPOINT ["/usr/bin/tini", "-g", "--", "/usr/local/bin/prefect-entrypoint.sh"]
then in the script
exec /opt/venv/bin/python -m \
prefect worker start \
--pool "$POOL" \
--limit "$LIMIT" \
--name "$WORKER_NAME" \
"$@"Nate
05/06/2026, 6:55 PMwe don't have full control on the k8s levelcan you create jobs with the access that you have?
Tom Han
05/06/2026, 6:57 PMTom Han
05/06/2026, 6:57 PM