Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dstack/supervisor/src/web_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::{anyhow, Result};
use or_panic::ResultOrPanic;
use rocket::figment::Figment;
use rocket::serde::json::Json;
use rocket::{delete, get, post, routes, Build, Rocket, State};
use rocket::{delete, get, post, routes, Build, Rocket, Shutdown, State};
use serde::{Deserialize, Serialize};
use tokio::signal;
use tracing::info;
Expand Down Expand Up @@ -81,8 +81,12 @@ fn clear(supervisor: &State<Supervisor>) -> Json<Response<()>> {
}

#[post("/shutdown")]
async fn shutdown(supervisor: &State<Supervisor>) -> Json<Response<()>> {
to_json(perform_shutdown(supervisor, false).await)
async fn shutdown(supervisor: &State<Supervisor>, rocket_shutdown: Shutdown) -> Json<Response<()>> {
let result = supervisor.shutdown().await;
if result.is_ok() {
rocket_shutdown.notify();
}
to_json(result)
}

async fn perform_shutdown(supervisor: &Supervisor, force: bool) -> Result<()> {
Expand Down
Loading