(composeCtx *composeBackupContext)
| 436 | } |
| 437 | |
| 438 | func stepStopComposeForBackup(composeCtx *composeBackupContext) error { |
| 439 | if composeCtx.stopped { |
| 440 | return nil |
| 441 | } |
| 442 | options := container.ListOptions{All: false} |
| 443 | options.Filters = filters.NewArgs(filters.Arg("label", composeProjectLabel+"="+composeCtx.composeName)) |
| 444 | runningList, err := composeCtx.dockerClient.ContainerList(context.Background(), options) |
| 445 | if err != nil { |
| 446 | return err |
| 447 | } |
| 448 | if len(runningList) == 0 { |
| 449 | return nil |
| 450 | } |
| 451 | if stdout, err := compose.Operate(composeCtx.composePath, "stop"); err != nil { |
| 452 | return fmt.Errorf("docker-compose stop failed, std: %s, err: %v", stdout, err) |
| 453 | } |
| 454 | composeCtx.stopped = true |
| 455 | return nil |
| 456 | } |
| 457 | |
| 458 | func stepStartComposeAfterBackup(composeCtx *composeBackupContext) error { |
| 459 | if !composeCtx.stopped { |
no test coverage detected