diff --git a/agent/app/dto/request/host_tool.go b/agent/app/dto/request/host_tool.go index cde9a351b..a784a1af4 100644 --- a/agent/app/dto/request/host_tool.go +++ b/agent/app/dto/request/host_tool.go @@ -34,6 +34,7 @@ type SupervisorProcessConfig struct { Numprocs string `json:"numprocs"` AutoRestart string `json:"autoRestart"` AutoStart string `json:"autoStart"` + Environment string `json:"environment"` } type SupervisorProcessFileReq struct { diff --git a/agent/app/dto/response/host_tool.go b/agent/app/dto/response/host_tool.go index 94dbd03c1..59ad0b2cb 100644 --- a/agent/app/dto/response/host_tool.go +++ b/agent/app/dto/response/host_tool.go @@ -32,6 +32,7 @@ type SupervisorProcessConfig struct { Status []ProcessStatus `json:"status"` AutoRestart string `json:"autoRestart"` AutoStart string `json:"autoStart"` + Environment string `json:"environment"` } type ProcessStatus struct { diff --git a/agent/app/service/host_tool.go b/agent/app/service/host_tool.go index c51f7684d..6609e3581 100644 --- a/agent/app/service/host_tool.go +++ b/agent/app/service/host_tool.go @@ -333,6 +333,9 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c _, _ = section.NewKey("priority", "999") _, _ = section.NewKey("numprocs", req.Numprocs) _, _ = section.NewKey("process_name", "%(program_name)s_%(process_num)02d") + if req.Environment != "" { + _, _ = section.NewKey("environment", req.Environment) + } if err = configFile.SaveTo(iniPath); err != nil { return err @@ -363,6 +366,8 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c autoRestart.SetValue(req.AutoRestart) autoStart := section.Key("autostart") autoStart.SetValue(req.AutoStart) + environment := section.Key("environment") + environment.SetValue(req.Environment) if err = configFile.SaveTo(iniPath); err != nil { return err @@ -435,6 +440,9 @@ func handleProcessConfig(configDir, containerName string) ([]response.Supervisor if autoStart, _ := section.GetKey("autostart"); autoStart != nil { config.AutoStart = autoStart.Value() } + if environment, _ := section.GetKey("environment"); environment != nil { + config.Environment = environment.Value() + } _ = getProcessStatus(&config, containerName) result = append(result, config) } diff --git a/frontend/src/api/interface/host-tool.ts b/frontend/src/api/interface/host-tool.ts index 0f0c2afdf..ba7b1b919 100644 --- a/frontend/src/api/interface/host-tool.ts +++ b/frontend/src/api/interface/host-tool.ts @@ -44,6 +44,7 @@ export namespace HostTool { status?: ProcessStatus[]; autoRestart: string; autoStart: string; + environment: string; } export interface ProcessStatus { diff --git a/frontend/src/api/interface/runtime.ts b/frontend/src/api/interface/runtime.ts index bedd5d0a3..ad442c640 100644 --- a/frontend/src/api/interface/runtime.ts +++ b/frontend/src/api/interface/runtime.ts @@ -213,6 +213,7 @@ export namespace Runtime { dir: string; numprocs: string; id: number; + environment: string; } export interface PHPContainerConfig { diff --git a/frontend/src/views/toolbox/supervisor/create/index.vue b/frontend/src/views/toolbox/supervisor/create/index.vue index fc7b22d18..d776b1b00 100644 --- a/frontend/src/views/toolbox/supervisor/create/index.vue +++ b/frontend/src/views/toolbox/supervisor/create/index.vue @@ -32,6 +32,9 @@ + + + {{ $t('tool.supervisor.autoRestartHelper') }} @@ -84,6 +87,7 @@ const initData = () => ({ numprocs: '1', autoRestart: 'true', autoStart: 'true', + environment: '', }); const process = ref(initData()); @@ -116,6 +120,7 @@ const acceptParams = (operate: string, config: HostTool.SupersivorProcess) => { numprocs: config.numprocs, autoRestart: config.autoRestart, autoStart: config.autoStart, + environment: config.environment || '', }; process.value.numprocsNum = Number(config.numprocs); } diff --git a/frontend/src/views/website/runtime/php/supervisor/create/index.vue b/frontend/src/views/website/runtime/php/supervisor/create/index.vue index 3a60381ba..7d7b4b4eb 100644 --- a/frontend/src/views/website/runtime/php/supervisor/create/index.vue +++ b/frontend/src/views/website/runtime/php/supervisor/create/index.vue @@ -29,6 +29,9 @@ + + + @@ -77,6 +80,7 @@ const initData = (runtimeID: number) => ({ id: runtimeID, autoRestart: 'true', autoStart: 'true', + environment: '', }); const process = ref(initData(0)); const em = defineEmits(['close']); @@ -105,6 +109,7 @@ const acceptParams = (operate: string, config: HostTool.SupersivorProcess, id: n id: id, autoRestart: config.autoRestart, autoStart: config.autoStart, + environment: config.environment || '', }; process.value.numprocsNum = Number(config.numprocs); }