From df4a4ad27303ba1d8da23287d8b5715c0b1eb9e2 Mon Sep 17 00:00:00 2001 From: Alexey Chirkov Date: Fri, 30 Jul 2021 12:03:37 +0300 Subject: [PATCH] isCanisterRunning detection fixed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `dfx canister status` command output has the following format: ``` ➜ weather_oracle git:(master) ✗ dfx canister status weather_oracle Canister status call result for weather_oracle. Status: Running Controller: rwlgt-iiaaa-aaaaa-aaaaa-cai Memory allocation: 0 Compute allocation: 0 Freezing threshold: 2_592_000 Memory Size: Nat(404999) Balance: 4_000_000_000_000 Cycles Module hash: 0xd52f6f15691fd9f2db3ec756d1faa1209d4590bfa1b18d734a765c313e054966 ``` So we should search for different string patterns. --- dfxservice.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dfxservice.go b/dfxservice.go index 02fdc98..e96de6e 100644 --- a/dfxservice.go +++ b/dfxservice.go @@ -125,11 +125,11 @@ func (s *DFXService) isCanisterRunning() (bool, error) { s.log.WithError(err).Errorln("Could not determine canister status:", output) return false, err } - if !strings.HasPrefix(output, "Canister "+s.config.CanisterName+"'s status is ") { + if !strings.HasPrefix(output, "Canister status call result for " + s.config.CanisterName) { s.log.WithError(err).Errorln("Could not determine canister status:", output) return false, fmt.Errorf("Could not determine canister status: %v", output) } - isRunning := strings.HasPrefix(output, "Canister "+s.config.CanisterName+"'s status is Running.") + isRunning := strings.HasPrefix(output, "Status: Running") return isRunning, nil }