Skip to content

Commit

Permalink
Merge pull request #109 from DeterminateSystems/colemickens/shutdown
Browse files Browse the repository at this point in the history
shutdown: wait for flakehub_cache first
  • Loading branch information
grahamc authored Nov 6, 2024
2 parents 925be77 + 647b207 commit cf18331
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions magic-nix-cache/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,23 @@ async fn workflow_finish(
gha_cache.shutdown().await?;
}

if let Some(attic_state) = state.flakehub_state.write().await.take() {
tracing::info!("Waiting for FlakeHub cache uploads to finish");
let paths = attic_state.push_session.wait().await?;

let paths = paths.keys().map(|s| s.name()).collect::<Vec<_>>();

tracing::info!(?paths, "FlakeHub Cache uploads completed");
} else {
tracing::info!("FlakeHub cache is not enabled, not uploading anything to it");
}

if let Some(sender) = state.shutdown_sender.lock().await.take() {
sender
.send(())
.map_err(|_| Error::Internal("Sending shutdown server message".to_owned()))?;
}

if let Some(attic_state) = state.flakehub_state.write().await.take() {
tracing::info!("Waiting for FlakeHub cache uploads to finish");
let _paths = attic_state.push_session.wait().await?;
}

// NOTE(cole-h): see `init_logging`
if let Some(logfile) = &state.logfile {
let logfile_contents = std::fs::read_to_string(logfile)
Expand Down
2 changes: 1 addition & 1 deletion magic-nix-cache/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ async fn main_cli() -> Result<()> {
Some(state)
}
Err(err) => {
tracing::debug!("FlakeHub cache initialization failed: {}", err);
tracing::error!("FlakeHub cache initialization failed: {}", err);
None
}
}
Expand Down

0 comments on commit cf18331

Please sign in to comment.