(req request.RuntimeOperate)
| 552 | } |
| 553 | |
| 554 | func (r *RuntimeService) OperateRuntime(req request.RuntimeOperate) error { |
| 555 | runtime, err := runtimeRepo.GetFirst(context.Background(), repo.WithByID(req.ID)) |
| 556 | if err != nil { |
| 557 | return err |
| 558 | } |
| 559 | defer func() { |
| 560 | if err != nil { |
| 561 | runtime.Status = constant.StatusError |
| 562 | runtime.Message = err.Error() |
| 563 | _ = runtimeRepo.Save(runtime) |
| 564 | } |
| 565 | }() |
| 566 | switch req.Operate { |
| 567 | case constant.RuntimeUp: |
| 568 | if err = runComposeCmdWithLog(req.Operate, runtime.GetComposePath(), runtime.GetLogPath()); err != nil { |
| 569 | return err |
| 570 | } |
| 571 | if err = SyncRuntimeContainerStatus(runtime); err != nil { |
| 572 | return err |
| 573 | } |
| 574 | case constant.RuntimeDown: |
| 575 | if err = runComposeCmdWithLog(req.Operate, runtime.GetComposePath(), runtime.GetLogPath()); err != nil { |
| 576 | return err |
| 577 | } |
| 578 | runtime.Status = constant.StatusStopped |
| 579 | case constant.RuntimeRestart: |
| 580 | if err = restartRuntime(runtime); err != nil { |
| 581 | return err |
| 582 | } |
| 583 | if err = SyncRuntimeContainerStatus(runtime); err != nil { |
| 584 | return err |
| 585 | } |
| 586 | } |
| 587 | return runtimeRepo.Save(runtime) |
| 588 | } |
| 589 | |
| 590 | func (r *RuntimeService) GetNodeModules(req request.NodeModuleReq) ([]response.NodeModule, error) { |
| 591 | runtime, err := runtimeRepo.GetFirst(context.Background(), repo.WithByID(req.ID)) |
nothing calls this directly
no test coverage detected