Commit 9bd7d7a
authored
fix: handle SIGTERM for graceful container shutdown (#1101)
## Summary
- Add a `trap` handler for SIGTERM/SIGINT that forwards signals to all
child processes
- Replace foreground `sleep infinity` with backgrounded `sleep infinity
& wait $!` so the trap can fire
**Root cause**: bash as PID 1 has no default SIGTERM handler, and
foreground `sleep infinity` blocks signal delivery. Docker sends SIGTERM
on stop, nothing handles it, so the container hangs until Docker sends
SIGKILL after the timeout.
Closes #1083
## Test plan
- [ ] `docker run --rm -d --name lgtm grafana/otel-lgtm` then `docker
stop lgtm` — should exit within a few seconds instead of hanging
- [ ] Verify all services start normally (health checks pass)
---------
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>1 parent 3b5cacd commit 9bd7d7a
2 files changed
+16
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
| 12 | + | |
14 | 13 | | |
15 | 14 | | |
16 | | - | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
5 | 16 | | |
6 | 17 | | |
7 | 18 | | |
| |||
156 | 167 | | |
157 | 168 | | |
158 | 169 | | |
159 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
0 commit comments