MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / handle_shutdown_signals

Function handle_shutdown_signals

supervisor/src/web_api.rs:108–138  ·  view source on GitHub ↗
(supervisor: Supervisor)

Source from the content-addressed store, hash-verified

106}
107
108async fn handle_shutdown_signals(supervisor: Supervisor) {
109 let ctrl_c = async {
110 signal::ctrl_c()
111 .await
112 .or_panic("failed to install Ctrl+C handler");
113 };
114
115 #[cfg(unix)]
116 let terminate = async {
117 signal::unix::signal(signal::unix::SignalKind::terminate())
118 .or_panic("failed to install signal handler")
119 .recv()
120 .await;
121 };
122
123 #[cfg(not(unix))]
124 let terminate = std::future::pending::<()>();
125
126 tokio::select! {
127 _ = ctrl_c => {
128 println!("Received Ctrl+C signal, initiating shutdown...");
129 }
130 _ = terminate => {
131 println!("Received terminate signal, initiating shutdown...");
132 }
133 }
134
135 perform_shutdown(&supervisor, true)
136 .await
137 .or_panic("Force shutdown should never return");
138}

Callers 1

rocketFunction · 0.85

Calls 1

perform_shutdownFunction · 0.85

Tested by

no test coverage detected