MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / checkRuntimePortExist

Function checkRuntimePortExist

agent/app/service/runtime_utils.go:911–940  ·  view source on GitHub ↗
(port int, scanPort bool, runtimeID uint)

Source from the content-addressed store, hash-verified

909}
910
911func 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
942func getExtensionDir(version string) string {
943 if strings.HasPrefix(version, "8.4") {

Callers 2

UpdateMethod · 0.85
UpdatePHPContainerMethod · 0.85

Calls 2

GetFirstMethod · 0.65
WithPortMethod · 0.65

Tested by

no test coverage detected