From dd736861bc589fe14311d2f7de8b2bfa93e4a1eb Mon Sep 17 00:00:00 2001 From: lucarin91 Date: Thu, 27 Nov 2025 10:56:41 +0100 Subject: [PATCH] fix: force app stop also if it isn't running --- internal/orchestrator/orchestrator.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/internal/orchestrator/orchestrator.go b/internal/orchestrator/orchestrator.go index 8eedff6f..fcb3402a 100644 --- a/internal/orchestrator/orchestrator.go +++ b/internal/orchestrator/orchestrator.go @@ -388,16 +388,6 @@ func stopAppWithCmd(ctx context.Context, docker command.Cli, app app.ArduinoApp, ctx, cancel := context.WithCancel(ctx) defer cancel() - appStatus, err := getAppStatus(ctx, docker, app) - if err != nil { - yield(StreamMessage{error: err}) - return - } - if appStatus.Status != StatusStarting && appStatus.Status != StatusRunning { - yield(StreamMessage{data: fmt.Sprintf("app %q is not running", app.Name)}) - return - } - if !yield(StreamMessage{data: fmt.Sprintf("Stopping app %q", app.Name)}) { return } @@ -413,7 +403,16 @@ func stopAppWithCmd(ctx context.Context, docker command.Cli, app app.ArduinoApp, }) if app.MainSketchPath != nil { - // TODO: check that the app sketch is running before attempting to stop it. + // Before stopping the microcontroller we want to make sure that the app was running. + appStatus, err := getAppStatus(ctx, docker, app) + if err != nil { + yield(StreamMessage{error: err}) + return + } + if appStatus.Status != StatusStarting && appStatus.Status != StatusRunning { + yield(StreamMessage{data: fmt.Sprintf("app %q is not running", app.Name)}) + return + } if err := micro.Disable(); err != nil { yield(StreamMessage{error: err})