(req request.NodeModuleOperateReq)
| 621 | } |
| 622 | |
| 623 | func (r *RuntimeService) OperateNodeModules(req request.NodeModuleOperateReq) error { |
| 624 | runtime, err := runtimeRepo.GetFirst(context.Background(), repo.WithByID(req.ID)) |
| 625 | if err != nil { |
| 626 | return err |
| 627 | } |
| 628 | containerName, err := env.GetEnvValueByKey(runtime.GetEnvPath(), "CONTAINER_NAME") |
| 629 | if err != nil { |
| 630 | return err |
| 631 | } |
| 632 | operation := getOperation(req.Operate, req.PkgManager) |
| 633 | execArgs := []string{"exec", "-i", containerName, req.PkgManager, operation} |
| 634 | if strings.TrimSpace(req.Module) != "" { |
| 635 | execArgs = append(execArgs, req.Module) |
| 636 | } |
| 637 | |
| 638 | ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute) |
| 639 | defer cancel() |
| 640 | installCmd := exec.CommandContext(ctx, "docker", execArgs...) |
| 641 | output, err := installCmd.CombinedOutput() |
| 642 | if err != nil { |
| 643 | return fmt.Errorf("failed to execute command: %s, error: %w", string(output), err) |
| 644 | } |
| 645 | return nil |
| 646 | } |
| 647 | |
| 648 | func (r *RuntimeService) SyncForRestart() error { |
| 649 | runtimes, err := runtimeRepo.List() |
nothing calls this directly
no test coverage detected