1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Process shutdown-signal handling shared by the long-running daemon event
//! loop and the one-shot Tempo fetch loop.
/// Resolves when the process receives a shutdown signal. SIGINT (Ctrl+C) is
/// handled on every platform; SIGTERM is also handled on Unix, which is what
/// Kubernetes sends on pod termination (rolling update, scale-down), what
/// `kill` sends by default, and what systemd uses to stop a unit. Callers
/// run the same graceful cleanup for either signal. On Windows only Ctrl+C
/// applies (there is no SIGTERM).
///
/// Build this future once and `tokio::pin!` it before a `select!` loop so the
/// signal listeners are registered a single time, not re-registered on every
/// iteration.
///
/// Caveat: on Unix, registering the SIGTERM handler is process-wide and
/// permanent. Tokio never restores the OS default disposition, so once this
/// future has been awaited, SIGTERM is caught (no longer fatal by default) for
/// the rest of the process lifetime, even after the future is dropped. For a
/// one-shot caller this means the process stops terminating by default on
/// SIGTERM after the first await (SIGKILL still applies). Harmless for the
/// long-running daemon, which wants exactly that for its whole lifetime.
pub async