Skip to content

Commit 88758fd

Browse files
Add Swarm example to the README
1 parent 3cf0ac4 commit 88758fd

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ When Puma receives `SIGTERM`, it begins shutting down immediately. In orchestrat
1010

1111
This plugin intercepts a configurable signal (default: `SIGQUIT`) and waits a configurable number of seconds before telling Puma to stop. This gives the orchestrator time to update its routing tables.
1212

13-
A typical Kubernetes setup would configure the pod's `preStop` hook or `terminationGracePeriodSeconds` to send `SIGQUIT`, then later `SIGTERM`:
13+
A typical Kubernetes setup would configure the pod's `preStop` hook to send `SIGQUIT` before the kubelet sends `SIGTERM`:
1414

1515
```yaml
1616
lifecycle:
@@ -19,6 +19,20 @@ lifecycle:
1919
command: ["kill", "-QUIT", "1"]
2020
```
2121
22+
In Docker Swarm, configure `stop_signal` to send `SIGQUIT` first and set `stop_grace_period` long enough to cover both the drain and Puma's graceful shutdown:
23+
24+
```yaml
25+
services:
26+
web:
27+
image: myapp:latest
28+
stop_signal: SIGQUIT
29+
stop_grace_period: 30s
30+
environment:
31+
PUMA_DELAYED_STOP_DRAIN_SECONDS: "5"
32+
```
33+
34+
Swarm sends `stop_signal` when removing a task, then waits up to `stop_grace_period` before sending `SIGKILL`. The plugin sleeps through the drain period while Swarm updates its routing mesh, then tells Puma to shut down gracefully with the remaining time.
35+
2236
## Installation
2337

2438
Add to your Gemfile:

0 commit comments

Comments
 (0)