(port int, scanPort bool, runtimeID uint)
| 909 | } |
| 910 | |
| 911 | func checkRuntimePortExist(port int, scanPort bool, runtimeID uint) error { |
| 912 | errMap := make(map[string]interface{}) |
| 913 | errMap["port"] = port |
| 914 | appInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithPort(port)) |
| 915 | if appInstall.ID > 0 { |
| 916 | errMap["type"] = i18n.GetMsgByKey("TYPE_APP") |
| 917 | errMap["name"] = appInstall.Name |
| 918 | return buserr.WithMap("ErrPortExist", errMap, nil) |
| 919 | } |
| 920 | opts := []repo.DBOption{runtimeRepo.WithPort(port)} |
| 921 | if runtimeID > 0 { |
| 922 | opts = append(opts, repo.WithByNOTID(runtimeID)) |
| 923 | } |
| 924 | runtime, _ := runtimeRepo.GetFirst(context.Background(), opts...) |
| 925 | if runtime != nil { |
| 926 | errMap["type"] = i18n.GetMsgByKey("TYPE_RUNTIME") |
| 927 | errMap["name"] = runtime.Name |
| 928 | return buserr.WithMap("ErrPortExist", errMap, nil) |
| 929 | } |
| 930 | domain, _ := websiteDomainRepo.GetFirst(websiteDomainRepo.WithPort(port)) |
| 931 | if domain.ID > 0 { |
| 932 | errMap["type"] = i18n.GetMsgByKey("TYPE_DOMAIN") |
| 933 | errMap["name"] = domain.Domain |
| 934 | return buserr.WithMap("ErrPortExist", errMap, nil) |
| 935 | } |
| 936 | if scanPort && common.ScanPort(port) { |
| 937 | return buserr.WithDetail("ErrPortInUsed", port, nil) |
| 938 | } |
| 939 | return nil |
| 940 | } |
| 941 | |
| 942 | func getExtensionDir(version string) string { |
| 943 | if strings.HasPrefix(version, "8.4") { |
no test coverage detected