Graceful shutdown¶
DataPress catches SIGTERM and SIGINT (Ctrl+C) and drains in-flight
requests before exiting. The grace period is configurable.
How it works¶
- The signal handler closes the listening socket — no new connections.
- Already-accepted requests get up to
shutdown_timeout_secsseconds to finish. - After the grace period (or once the last in-flight request completes), workers are stopped and the process exits cleanly.
The startup log records which signal triggered shutdown:
INFO Received SIGTERM, shutting down gracefully (up to 30s for in-flight requests)...
INFO Shutdown complete.
On non-Unix platforms (Windows), only Ctrl+C is honoured — SIGTERM
isn't a thing there.
Configure the grace period¶
Choose the value based on your workload:
- Short (
5–10s) — interactive UI workloads where every handler returns quickly. Faster pod restarts during rolling deploys. - Default (
30s) — bulk queries, medium aggregations. - Long (
120+ s) — large parquet exports, expensive aggregations on big datasets. Match this to the longest realistic handler duration.
Tuning with the orchestrator¶
The orchestrator's "terminationGracePeriodSeconds" must be strictly
greater than shutdown_timeout_secs, otherwise the pod gets
SIGKILL'd before DataPress can finish draining.
spec:
terminationGracePeriodSeconds: 45 # > shutdown_timeout_secs (30)
containers:
- name: datapress
# ...
env:
- name: RUST_LOG
value: info
For zero-downtime rolling deploys, also ensure:
- The readiness probe (
/readyz) is wired up so the load balancer stops sending new traffic the moment a pod begins shutting down. - The new pod is fully ready before the old one is torn down.