From a0ad263d271bb900e7e20e37ab00335f7f2ffe6b Mon Sep 17 00:00:00 2001 From: Iulian Barbu Date: Thu, 7 Sep 2023 14:57:01 +0300 Subject: [PATCH] fix(cargo-shuttle): break deploy logs stream when... ...StartResponse is received --- cargo-shuttle/src/lib.rs | 13 ++++++++++++- common/src/deployment.rs | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 99b0636988..54652cad1e 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -13,7 +13,9 @@ use std::path::{Path, PathBuf}; use std::process::exit; use std::str::FromStr; -use shuttle_common::deployment::{DEPLOYER_END_MESSAGES_BAD, DEPLOYER_END_MESSAGES_GOOD}; +use shuttle_common::deployment::{ + DEPLOYER_END_MESSAGES_BAD, DEPLOYER_END_MESSAGES_GOOD, DEPLOYER_START_RESPONSE, +}; use shuttle_common::models::deployment::CREATE_SERVICE_BODY_LIMIT; use shuttle_common::{ claims::{ClaimService, InjectPropagation}, @@ -1157,6 +1159,7 @@ impl Shuttle { return Ok(CommandOutcome::DeploymentFailure); } + if DEPLOYER_END_MESSAGES_GOOD .iter() .any(|m| log_item.line.contains(m)) @@ -1164,6 +1167,11 @@ impl Shuttle { debug!("received end message, breaking deployment stream"); break; } + + if log_item.line.contains(DEPLOYER_START_RESPONSE) { + debug!("received start response inside the logs, breaking the loop"); + break; + } } } else { eprintln!("--- Reconnecting websockets logging ---"); @@ -1223,6 +1231,9 @@ impl Shuttle { return Ok(CommandOutcome::DeploymentFailure); } + // Print a newline in between the last deployment log line and the deployment details. + println!(); + let service = client.get_service(self.ctx.project_name()).await?; let resources = client .get_service_resources(self.ctx.project_name()) diff --git a/common/src/deployment.rs b/common/src/deployment.rs index 15670eb80b..83f1ffc549 100644 --- a/common/src/deployment.rs +++ b/common/src/deployment.rs @@ -32,6 +32,7 @@ pub const DEPLOYER_END_MSG_STARTUP_ERR: &str = "Service startup encountered an e pub const DEPLOYER_END_MSG_CRASHED: &str = "Service encountered an error and crashed"; pub const DEPLOYER_END_MSG_STOPPED: &str = "Service was stopped by the user"; pub const DEPLOYER_END_MSG_COMPLETED: &str = "Service finished running all on its own"; +pub const DEPLOYER_START_RESPONSE: &str = r#" [Deployer] {response="StartResponse { success: "#; pub const DEPLOYER_END_MESSAGES_BAD: &[&str] = &[DEPLOYER_END_MSG_STARTUP_ERR, DEPLOYER_END_MSG_CRASHED];