Roman Bedroš
05/27/2026, 11:22 AMMarvin
05/27/2026, 11:22 AMMarvin
05/27/2026, 11:25 AMprefect server does not automatically pause deployments or schedules. When the server shuts down, the scheduler stops, but your deployments stay active in the database. When the server comes back, scheduling resumes.
What does work is pausing schedules as part of your container shutdown process.
Recommended approach
If your goal is “don’t create any new scheduled runs when I stop the container”, run this before the server exits:
bash
prefect deployment schedule pause --all
And when you want scheduling back:
bash
prefect deployment schedule resume --all
I verified those CLI commands exist in Prefect 3.
A simple container entrypoint pattern would be:
bash
#!/bin/sh
set -e
prefect server start --host 0.0.0.0 &
SERVER_PID=$!
shutdown() {
echo "Pausing all deployment schedules..."
prefect deployment schedule pause --all || true
kill "$SERVER_PID"
wait "$SERVER_PID"
}
trap shutdown TERM INT
wait "$SERVER_PID"
A few important caveats:
- Pausing schedules prevents new scheduled runs from being created.
- It does not cancel runs that were already created and are still in Scheduled state.
- If you also run workers separately, those workers may still pick up already-scheduled runs unless you stop the workers too.
- On restart, if you resume schedules, behavior for missed time depends on the schedule/catchup configuration.
So if you want a full stop, usually you should:
1. stop workers
2. pause schedules
3. stop the server
Useful docs:
- Create schedules
- Deployments
- Prefect server overview
If you want, I can help you turn this into:
- a Dockerfile/entrypoint example
- a docker-compose setup
- or a version that also cancels already scheduled runs before shutdown.