1use tokio::signal;
2use tracing::info;
3
4#[cfg(feature = "env")]
5pub mod envx;
6
7#[cfg(feature = "http_server")]
8pub mod httpx;
9
10#[cfg(feature = "http_server")]
11pub mod tracex;
12
13#[cfg(feature = "http_client")]
14pub mod http_clientx;
15
16#[cfg(feature = "outbox")]
17pub mod outboxx;
18
19#[cfg(any(feature = "aws", feature = "env_from_secrets_manager"))]
20pub mod awsx;
21
22#[cfg(any(feature = "statsd", feature = "prometheus"))]
23pub mod metricx;
24
25#[cfg(any(feature = "postgres", feature = "outbox"))]
26pub mod databasex;
27
28#[cfg(feature = "growthbook")]
29pub mod growthbookx;
30
31pub async fn shutdown_signal() {
32 let ctrl_c = async {
33 signal::ctrl_c()
34 .await
35 .expect("Failed to install Ctrl+C handler");
36 };
37
38 let terminate = async {
39 signal::unix::signal(signal::unix::SignalKind::terminate())
40 .expect("Failed to install signal handler")
41 .recv()
42 .await;
43 };
44
45 tokio::select! {
46 _ = ctrl_c => {},
47 _ = terminate => {},
48 }
49
50 info!("Starting graceful shutdown");
51}