pub fn installed_shutdown_signal() -> impl Future<Output = ()> + Send + 'staticExpand description
Resolves when this process is asked to stop: SIGTERM, or Ctrl-C. The
handlers are registered before this returns.
SIGTERM is the half a deployment actually uses: docker stop sends it,
systemd’s own ExecStop sends it, and a process that is PID 1 in a
container — which this one is, see the Dockerfile’s ENTRYPOINT — gets
no default disposition for it, so an unhandled SIGTERM is not a
termination but a signal that is silently discarded. Waiting only on
Ctrl-C therefore meant every stop ran to its grace period and ended in
SIGKILL, skipping the write-ahead log’s flush on the way out.
Public because more than one thing has to observe it. serve_router
stops accepting on it, and a caller that parks a request — the decision
long poll — waits on its own copy so a shutdown does not have to sit out
that request’s whole window. Awaiting it more than once is fine; each
caller installs its own listener.
tokio hands a signal only to the listeners that existed when it arrived, so
the gap between building an observation and first polling it is a gap a
stop can fall into. serve_router holds that gap open across the whole of
its setup — it announces the listener, and only the accept loop that runs
afterwards polls the shutdown future — which is long enough for a real
docker stop to land in it.