@@ -188,7 +188,7 @@ func StartApp(ctx context.Context, docker *dockerClient.Client, provisioner *Pro
188188 return
189189 }
190190 }
191- _ = yield (StreamMessage {Type : ProgressType , progress : & Progress {Name : "" , Progress : 100 .0 }})
191+ _ = yield (StreamMessage {Type : ProgressType , progress : & Progress {Name : "" , Progress : 1 .0 }})
192192 }
193193}
194194
@@ -198,7 +198,7 @@ func StopApp(ctx context.Context, app app.ArduinoApp) iter.Seq[StreamMessage] {
198198 defer cancel ()
199199
200200 callbackWriter := NewCallbackWriter (func (line string ) {
201- if ! yield (StreamMessage {data : line }) {
201+ if ! yield (StreamMessage {Type : DebugType , data : line }) {
202202 cancel ()
203203 return
204204 }
@@ -209,35 +209,46 @@ func StopApp(ctx context.Context, app app.ArduinoApp) iter.Seq[StreamMessage] {
209209 if micro .OnBoard {
210210 // On imola we could just disable the microcontroller
211211 if err := micro .Disable (context .Background (), nil ); err != nil {
212- yield (StreamMessage {error : err })
212+ yield (StreamMessage {Type : ErrorType , error : err })
213213 return
214214 }
215215 }
216216 }
217217
218218 if app .MainPythonFile != nil {
219+ if ! yield (StreamMessage {Type : InfoType , data : "stopping the app..." }) {
220+ cancel ()
221+ return
222+ }
219223 provisioningStateDir , err := getProvisioningStateDir (app )
220224 if err != nil {
221- yield (StreamMessage {error : err })
225+ yield (StreamMessage {Type : ErrorType , error : err })
222226 return
223227 }
224228 mainCompose := provisioningStateDir .Join ("app-compose.yaml" )
225229 // In case the app was never started
226230 if mainCompose .Exist () {
227- process , err := paths .NewProcess (nil , "docker" , "compose" , "-f" , mainCompose .String (), "stop" , fmt .Sprintf ("--timeout=%d" , DefaultDockerStopTimeoutSeconds ))
231+
232+ command := []string {"docker" , "compose" , "-f" , mainCompose .String (), "stop" , fmt .Sprintf ("--timeout=%d" , DefaultDockerStopTimeoutSeconds )}
233+ if ! yield (StreamMessage {Type : DebugType , data : "Executing command: " + strings .Join (command , " " )}) {
234+ return
235+ }
236+ process , err := paths .NewProcess (nil , command ... )
228237 if err != nil {
229- yield (StreamMessage {error : err })
238+ yield (StreamMessage {Type : ErrorType , error : err })
230239 return
231240 }
232241 process .RedirectStderrTo (callbackWriter )
233242 process .RedirectStdoutTo (callbackWriter )
234243 if err := process .RunWithinContext (ctx ); err != nil {
235- yield (StreamMessage {error : err })
244+ yield (StreamMessage {Type : ErrorType , error : err })
236245 return
237246 }
247+ } else if ! yield (StreamMessage {Type : InfoType , data : "App not running, nothing to stop." }) {
248+ return
238249 }
239250 }
240- _ = yield (StreamMessage {progress : & Progress {Name : "" , Progress : 100 .0 }})
251+ _ = yield (StreamMessage {Type : ProgressType , progress : & Progress {Name : "" , Progress : 1 .0 }})
241252 }
242253}
243254
0 commit comments