Check if the serai wasm was built successfully by verifying the build container's status code and state, instead of checking the volume mountpoint locally

This commit is contained in:
rlking
2024-05-24 17:44:37 +02:00
parent 1d2beb3ee4
commit 294212238f

View File

@@ -382,23 +382,17 @@ fn start(network: Network, services: HashSet<String>) {
let serai_runtime_volume = format!("serai-{}-runtime-volume", network.label()); let serai_runtime_volume = format!("serai-{}-runtime-volume", network.label());
if name == "serai" { if name == "serai" {
// Check if it's built by checking if the volume has the expected runtime file // Check if it's built by checking if the volume has the expected runtime file
let wasm_build_container_name = format!("serai-{}-runtime", network.label());
let built = || { let built = || {
if let Ok(path) = Command::new("docker") if let Ok(state_and_status) = Command::new("docker")
.arg("volume")
.arg("inspect") .arg("inspect")
.arg("-f") .arg("-f")
.arg("{{ .Mountpoint }}") .arg("{{.State.Status}}:{{.State.ExitCode}}")
.arg(&serai_runtime_volume) .arg(&wasm_build_container_name)
.output() .output()
{ {
if let Ok(path) = String::from_utf8(path.stdout) { if let Ok(state_and_status) = String::from_utf8(state_and_status.stdout) {
if let Ok(iter) = std::fs::read_dir(PathBuf::from(path.trim())) { return state_and_status.trim() == "exited:0";
for item in iter.flatten() {
if item.file_name() == "serai.wasm" {
return true;
}
}
}
} }
} }
false false