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: stabilise redeploy command #1966

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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: stabilise redeploy command, print logs on fail
  • Loading branch information
jonaro00 committed Jan 20, 2025
commit b0a3f5abdfe6ed65715d5fc7a518ee456d60f2fd
1 change: 0 additions & 1 deletion cargo-shuttle/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ pub enum DeploymentCommand {
id: Option<String>,
},
/// Redeploy a previous deployment (if possible)
#[command(visible_alias = "re", hide = true)]
Redeploy {
/// ID of deployment to redeploy
id: String,
Expand Down
48 changes: 28 additions & 20 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,8 +1424,7 @@ impl Shuttle {
let pid = self.ctx.project_id();
let deployment = client.redeploy_beta(pid, &deployment_id).await?;

// TODO?: Make it print logs on fail
self.track_deployment_status_beta(pid, &deployment.id)
self.track_deployment_status_and_print_logs_on_fail(pid, &deployment.id, false)
.await?;

Ok(())
Expand Down Expand Up @@ -2451,8 +2450,7 @@ impl Shuttle {
return Ok(());
}

// TODO?: Make it print logs on fail
self.track_deployment_status_beta(pid, &deployment.id)
self.track_deployment_status_and_print_logs_on_fail(pid, &deployment.id, args.raw)
.await?;

return Ok(());
Expand Down Expand Up @@ -2590,22 +2588,8 @@ impl Shuttle {
return Ok(());
}

if self
.track_deployment_status_beta(pid, &deployment.id)
.await?
{
for log in client
.get_deployment_logs_beta(pid, &deployment.id)
.await?
.logs
{
if args.raw {
println!("{}", log.line);
} else {
println!("{log}");
}
}
}
self.track_deployment_status_and_print_logs_on_fail(pid, &deployment.id, args.raw)
.await?;

return Ok(());
}
Expand Down Expand Up @@ -2820,6 +2804,30 @@ impl Shuttle {
Ok(failed)
}

async fn track_deployment_status_and_print_logs_on_fail(
&self,
proj_id: &str,
depl_id: &str,
raw: bool,
) -> Result<()> {
let client = self.client.as_ref().unwrap();
if self.track_deployment_status_beta(proj_id, depl_id).await? {
for log in client
jonaro00 marked this conversation as resolved.
Show resolved Hide resolved
.get_deployment_logs_beta(proj_id, &depl_id)
.await?
.logs
{
if raw {
println!("{}", log.line);
} else {
println!("{log}");
}
}
}

Ok(())
}

async fn project_start(&self, idle_minutes: u64) -> Result<()> {
let client = self.client.as_ref().unwrap();
let config = &project::Config { idle_minutes };
Expand Down