@@ -109,26 +109,23 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
109109 if exist != nil {
110110 return nil , buserr .New (constant .ErrImageExist )
111111 }
112- portValue , _ := create .Params ["PANEL_APP_PORT_HTTP" ]
113- if portValue != nil {
114- if err := checkPortExist (int (portValue .(float64 ))); err != nil {
115- return nil , err
116- }
117- }
118112 case constant .RuntimeNode , constant .RuntimeJava , constant .RuntimeGo , constant .RuntimePython , constant .RuntimeDotNet :
119113 if ! fileOp .Stat (create .CodeDir ) {
120114 return nil , buserr .New (constant .ErrPathNotFound )
121115 }
122116 create .Install = true
123- if err := checkPortExist (create .Port ); err != nil {
124- return nil , err
125- }
126117 for _ , export := range create .ExposedPorts {
127118 if err := checkPortExist (export .HostPort ); err != nil {
128119 return nil , err
129120 }
130121 }
131122 }
123+ portValue , _ := create .Params ["PANEL_APP_PORT_HTTP" ]
124+ if portValue != nil {
125+ if err := checkPortExist (int (portValue .(float64 ))); err != nil {
126+ return nil , err
127+ }
128+ }
132129 containerName , ok := create .Params ["CONTAINER_NAME" ]
133130 if ! ok {
134131 return nil , buserr .New ("ErrContainerNameIsNull" )
@@ -161,17 +158,16 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (*model.Runtime, e
161158 Resource : create .Resource ,
162159 Version : create .Version ,
163160 ContainerName : containerName .(string ),
161+ Port : int (portValue .(float64 )),
164162 }
165163
166164 switch create .Type {
167165 case constant .RuntimePHP :
168- runtime .Port = int (create .Params ["PANEL_APP_PORT_HTTP" ].(float64 ))
169166 if err = handlePHP (create , runtime , fileOp , appVersionDir ); err != nil {
170167 return nil , err
171168 }
172169 case constant .RuntimeNode , constant .RuntimeJava , constant .RuntimeGo , constant .RuntimePython , constant .RuntimeDotNet :
173- runtime .Port = int (create .Params ["port" ].(float64 ))
174- if err = handleNodeAndJava (create , runtime , fileOp , appVersionDir ); err != nil {
170+ if err = handleRuntime (create , runtime , fileOp , appVersionDir ); err != nil {
175171 return nil , err
176172 }
177173 }
@@ -356,7 +352,7 @@ func (r *RuntimeService) Get(id uint) (*response.RuntimeDTO, error) {
356352 }
357353 for k , v := range envs {
358354 switch k {
359- case "NODE_APP_PORT" , "PANEL_APP_PORT_HTTP" , "JAVA_APP_PORT" , "GO_APP_PORT" , " APP_PORT" , "port " :
355+ case "APP_PORT" , "PANEL_APP_PORT_HTTP " :
360356 port , err := strconv .Atoi (v )
361357 if err != nil {
362358 return nil , err
@@ -440,19 +436,19 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
440436 }
441437 oldImage := runtime .Image
442438 oldEnv := runtime .Env
443- req . Port = int (req .Params ["port " ].(float64 ))
439+ port : = int (req .Params ["PANEL_APP_PORT_HTTP " ].(float64 ))
444440 switch runtime .Type {
445441 case constant .RuntimePHP :
446442 exist , _ := runtimeRepo .GetFirst (runtimeRepo .WithImage (req .Name ), runtimeRepo .WithNotId (req .ID ))
447443 if exist != nil {
448444 return buserr .New (constant .ErrImageExist )
449445 }
450446 case constant .RuntimeNode , constant .RuntimeJava , constant .RuntimeGo , constant .RuntimePython , constant .RuntimeDotNet :
451- if runtime .Port != req . Port {
452- if err = checkPortExist (req . Port ); err != nil {
447+ if runtime .Port != port {
448+ if err = checkPortExist (port ); err != nil {
453449 return err
454450 }
455- runtime .Port = req . Port
451+ runtime .Port = port
456452 }
457453 for _ , export := range req .ExposedPorts {
458454 if err = checkPortExist (export .HostPort ); err != nil {
@@ -494,7 +490,6 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
494490 CodeDir : req .CodeDir ,
495491 Version : req .Version ,
496492 NodeConfig : request.NodeConfig {
497- Port : req .Port ,
498493 Install : true ,
499494 ExposedPorts : req .ExposedPorts ,
500495 Environments : req .Environments ,
@@ -526,7 +521,7 @@ func (r *RuntimeService) Update(req request.RuntimeUpdate) error {
526521 case constant .RuntimeNode , constant .RuntimeJava , constant .RuntimeGo , constant .RuntimePython , constant .RuntimeDotNet :
527522 runtime .Version = req .Version
528523 runtime .CodeDir = req .CodeDir
529- runtime .Port = req . Port
524+ runtime .Port = port
530525 runtime .Status = constant .RuntimeReCreating
531526 _ = runtimeRepo .Save (runtime )
532527 go reCreateRuntime (runtime )
0 commit comments