Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show progress bar on stopping service #628

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Changes from 1 commit
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
Next Next commit
feat: make stop service return summary of active deployment
  • Loading branch information
oddgrd committed Feb 13, 2023
commit 4f0e2ac17b22030aeb07b1d2aaddba0cee6e38a7
21 changes: 9 additions & 12 deletions deployer/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,16 @@ async fn post_service(
async fn stop_service(
Extension(persistence): Extension<Persistence>,
Extension(deployment_manager): Extension<DeploymentManager>,
Extension(proxy_fqdn): Extension<FQDN>,
Path((project_name, service_name)): Path<(String, String)>,
) -> Result<Json<shuttle_common::models::service::Detailed>> {
) -> Result<Json<shuttle_common::models::service::Summary>> {
if let Some(service) = persistence.get_service_by_name(&service_name).await? {
let old_deployments = persistence.get_deployments(&service.id).await?;
let running_deployment = persistence.get_active_deployment(&service.id).await?;

for deployment in old_deployments.iter() {
if let Some(ref deployment) = running_deployment {
deployment_manager.kill(deployment.id).await;
} else {
return Err(Error::NotFound);
}

let resources = persistence
Expand All @@ -268,18 +271,12 @@ async fn stop_service(
.into_iter()
.map(Into::into)
.collect();
let secrets = persistence
.get_secrets(&service.id)
.await?
.into_iter()
.map(Into::into)
.collect();

let response = shuttle_common::models::service::Detailed {
let response = shuttle_common::models::service::Summary {
name: service.name,
deployments: old_deployments.into_iter().map(Into::into).collect(),
deployment: running_deployment.map(Into::into),
resources,
secrets,
uri: format!("https://{proxy_fqdn}"),
};

Ok(Json(response))
Expand Down