<@ULVA73B9P> Is there a way how to automatically p...
# marvin-ai
r
@Marvin Is there a way how to automatically pause all deployments when prefect server is terminated? I run open source prefect server in a rootless container and i need the flows to be paused when I stop the container.
m
thought for 161.3 seconds
Short answer: not automatically, no. In Prefect 3 OSS, stopping
prefect 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:
Copy code
bash
prefect deployment schedule pause --all
And when you want scheduling back:
Copy code
bash
prefect deployment schedule resume --all
I verified those CLI commands exist in Prefect 3. A simple container entrypoint pattern would be:
Copy code
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.