From 7add6ab19008e784542fb4347bcc4796f3e9c92e Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 25 Sep 2024 21:58:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20PHP=20=E8=BF=90=E8=A1=8C=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=A2=9E=E5=8A=A0=E8=BF=9B=E7=A8=8B=E5=AE=88=E6=8A=A4?= =?UTF-8?q?=E7=AE=A1=E7=90=86=20(#6580)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/app/api/v2/runtime.go | 64 ++++ agent/app/dto/request/host_tool.go | 1 + agent/app/dto/request/runtime.go | 10 + agent/app/service/host_tool.go | 162 +++++---- agent/app/service/runtime.go | 33 ++ agent/app/service/website.go | 7 +- agent/router/ro_runtime.go | 4 + frontend/src/api/interface/runtime.ts | 24 ++ frontend/src/api/modules/runtime.ts | 17 + frontend/src/components/drawer-pro/index.vue | 2 + .../src/views/website/runtime/php/index.vue | 18 +- .../runtime/php/supervisor/create/index.vue | 133 ++++++++ .../runtime/php/supervisor/file/index.vue | 148 ++++++++ .../website/runtime/php/supervisor/index.vue | 316 ++++++++++++++++++ .../website/website/config/basic/index.vue | 2 +- .../website/nginx/module/build/index.vue | 1 + 16 files changed, 879 insertions(+), 63 deletions(-) create mode 100644 frontend/src/views/website/runtime/php/supervisor/create/index.vue create mode 100644 frontend/src/views/website/runtime/php/supervisor/file/index.vue create mode 100644 frontend/src/views/website/runtime/php/supervisor/index.vue diff --git a/agent/app/api/v2/runtime.go b/agent/app/api/v2/runtime.go index 2da89cb37..a1ccda3b1 100644 --- a/agent/app/api/v2/runtime.go +++ b/agent/app/api/v2/runtime.go @@ -431,3 +431,67 @@ func (b *BaseApi) GetFPMConfig(c *gin.Context) { } helper.SuccessWithData(c, data) } + +// @Tags Runtime +// @Summary Get supervisor process +// @Description 获取 supervisor 进程 +// @Accept json +// @Param id path integer true "request" +// @Success 200 {object} response.SupervisorProcess +// @Security ApiKeyAuth +// @Router /runtimes/supervisor/process/:id [get] +func (b *BaseApi) GetSupervisorProcess(c *gin.Context) { + id, err := helper.GetParamID(c) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil) + return + } + data, err := runtimeService.GetSupervisorProcess(id) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, data) +} + +// @Tags Runtime +// @Summary Operate supervisor process +// @Description 操作 supervisor 进程 +// @Accept json +// @Param request body request.PHPSupervisorProcessConfig true "request" +// @Success 200 +// @Security ApiKeyAuth +// @Router /runtimes/supervisor/process/operate [post] +func (b *BaseApi) OperateSupervisorProcess(c *gin.Context) { + var req request.PHPSupervisorProcessConfig + if err := helper.CheckBindAndValidate(&req, c); err != nil { + return + } + err := runtimeService.OperateSupervisorProcess(req) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithOutData(c) +} + +// @Tags Runtime +// @Summary Operate supervisor process file +// @Description 操作 supervisor 进程文件 +// @Accept json +// @Param request body request.PHPSupervisorProcessFileReq true "request" +// @Success 200 +// @Security ApiKeyAuth +// @Router /runtimes/supervisor/process/file/operate [post] +func (b *BaseApi) OperateSupervisorProcessFile(c *gin.Context) { + var req request.PHPSupervisorProcessFileReq + if err := helper.CheckBindAndValidate(&req, c); err != nil { + return + } + res, err := runtimeService.OperateSupervisorProcessFile(req) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, res) +} diff --git a/agent/app/dto/request/host_tool.go b/agent/app/dto/request/host_tool.go index aef43182d..9d602a19a 100644 --- a/agent/app/dto/request/host_tool.go +++ b/agent/app/dto/request/host_tool.go @@ -33,6 +33,7 @@ type SupervisorProcessConfig struct { Dir string `json:"dir"` Numprocs string `json:"numprocs"` } + type SupervisorProcessFileReq struct { Name string `json:"name" validate:"required"` Operate string `json:"operate" validate:"required,oneof=get clear update" ` diff --git a/agent/app/dto/request/runtime.go b/agent/app/dto/request/runtime.go index 9243321df..1af6d0b24 100644 --- a/agent/app/dto/request/runtime.go +++ b/agent/app/dto/request/runtime.go @@ -100,3 +100,13 @@ type FPMConfig struct { ID uint `json:"id" validate:"required"` Params map[string]interface{} `json:"params" validate:"required"` } + +type PHPSupervisorProcessConfig struct { + ID uint `json:"id" validate:"required"` + SupervisorProcessConfig +} + +type PHPSupervisorProcessFileReq struct { + ID uint `json:"id" validate:"required"` + SupervisorProcessFileReq +} diff --git a/agent/app/service/host_tool.go b/agent/app/service/host_tool.go index 6252171f3..ff6bf01ae 100644 --- a/agent/app/service/host_tool.go +++ b/agent/app/service/host_tool.go @@ -3,11 +3,13 @@ package service import ( "bytes" "fmt" + "os" "os/exec" "os/user" "path" "strconv" "strings" + "time" "github.com/1Panel-dev/1Panel/agent/app/dto/request" "github.com/1Panel-dev/1Panel/agent/app/dto/response" @@ -281,11 +283,6 @@ func (h *HostToolService) GetToolLog(req request.HostToolLogReq) (string, error) func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcessConfig) error { var ( supervisordDir = path.Join(global.CONF.System.BaseDir, "1panel", "tools", "supervisord") - logDir = path.Join(supervisordDir, "log") - includeDir = path.Join(supervisordDir, "supervisor.d") - outLog = path.Join(logDir, fmt.Sprintf("%s.out.log", req.Name)) - errLog = path.Join(logDir, fmt.Sprintf("%s.err.log", req.Name)) - iniPath = path.Join(includeDir, fmt.Sprintf("%s.ini", req.Name)) fileOp = files.NewFileOp() ) if req.Operate == "update" || req.Operate == "create" { @@ -297,7 +294,22 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess return buserr.WithMap("ErrUserFindErr", map[string]interface{}{"name": req.User, "err": err.Error()}, err) } } + return handleProcess(supervisordDir, req, "") +} +func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, containerName string) error { + var ( + fileOp = files.NewFileOp() + logDir = path.Join(supervisordDir, "log") + includeDir = path.Join(supervisordDir, "supervisor.d") + outLog = path.Join(logDir, fmt.Sprintf("%s.out.log", req.Name)) + errLog = path.Join(logDir, fmt.Sprintf("%s.err.log", req.Name)) + iniPath = path.Join(includeDir, fmt.Sprintf("%s.ini", req.Name)) + ) + if containerName != "" { + outLog = path.Join("/var/log/supervisor", fmt.Sprintf("%s.out.log", req.Name)) + errLog = path.Join("/var/log/supervisor", fmt.Sprintf("%s.err.log", req.Name)) + } switch req.Operate { case "create": if fileOp.Stat(iniPath) { @@ -324,10 +336,10 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess if err = configFile.SaveTo(iniPath); err != nil { return err } - if err := operateSupervisorCtl("reread", "", ""); err != nil { + if err := operateSupervisorCtl("reread", "", "", includeDir, containerName); err != nil { return err } - return operateSupervisorCtl("update", "", "") + return operateSupervisorCtl("update", "", "", includeDir, containerName) case "update": configFile, err := ini.Load(iniPath) if err != nil { @@ -350,52 +362,54 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess if err = configFile.SaveTo(iniPath); err != nil { return err } - if err := operateSupervisorCtl("reread", "", ""); err != nil { + if err := operateSupervisorCtl("reread", "", "", includeDir, containerName); err != nil { return err } - return operateSupervisorCtl("update", "", "") + return operateSupervisorCtl("update", "", "", includeDir, containerName) case "restart": - return operateSupervisorCtl("restart", req.Name, "") + return operateSupervisorCtl("restart", req.Name, "", includeDir, containerName) case "start": - return operateSupervisorCtl("start", req.Name, "") + return operateSupervisorCtl("start", req.Name, "", includeDir, containerName) case "stop": - return operateSupervisorCtl("stop", req.Name, "") + return operateSupervisorCtl("stop", req.Name, "", includeDir, containerName) case "delete": - _ = operateSupervisorCtl("remove", "", req.Name) - _ = files.NewFileOp().DeleteFile(iniPath) - _ = files.NewFileOp().DeleteFile(outLog) - _ = files.NewFileOp().DeleteFile(errLog) - if err := operateSupervisorCtl("reread", "", ""); err != nil { + _ = operateSupervisorCtl("remove", "", req.Name, includeDir, containerName) + _ = fileOp.DeleteFile(iniPath) + _ = fileOp.DeleteFile(outLog) + _ = fileOp.DeleteFile(errLog) + if err := operateSupervisorCtl("reread", "", "", includeDir, containerName); err != nil { return err } - return operateSupervisorCtl("update", "", "") + return operateSupervisorCtl("update", "", "", includeDir, containerName) } - return nil } -func (h *HostToolService) GetSupervisorProcessConfig() ([]response.SupervisorProcessConfig, error) { +func handleProcessConfig(configDir, containerName string) ([]response.SupervisorProcessConfig, error) { var ( result []response.SupervisorProcessConfig ) - configDir := path.Join(global.CONF.System.BaseDir, "1panel", "tools", "supervisord", "supervisor.d") - fileList, _ := NewIFileService().GetFileList(request.FileOption{FileOption: files.FileOption{Path: configDir, Expand: true, Page: 1, PageSize: 100}}) - if len(fileList.Items) == 0 { - return result, nil + entries, err := os.ReadDir(configDir) + if err != nil { + return nil, err } - for _, configFile := range fileList.Items { - f, err := ini.Load(configFile.Path) - if err != nil { - global.LOG.Errorf("get %s file err %s", configFile.Name, err.Error()) + for _, entry := range entries { + if entry.IsDir() { continue } - if strings.HasSuffix(configFile.Name, ".ini") { + fileName := entry.Name() + f, err := ini.Load(path.Join(configDir, fileName)) + if err != nil { + global.LOG.Errorf("get %s file err %s", fileName, err.Error()) + continue + } + if strings.HasSuffix(fileName, ".ini") { config := response.SupervisorProcessConfig{} - name := strings.TrimSuffix(configFile.Name, ".ini") + name := strings.TrimSuffix(fileName, ".ini") config.Name = name section, err := f.GetSection(fmt.Sprintf("program:%s", name)) if err != nil { - global.LOG.Errorf("get %s file section err %s", configFile.Name, err.Error()) + global.LOG.Errorf("get %s file section err %s", fileName, err.Error()) continue } if command, _ := section.GetKey("command"); command != nil { @@ -410,52 +424,69 @@ func (h *HostToolService) GetSupervisorProcessConfig() ([]response.SupervisorPro if numprocs, _ := section.GetKey("numprocs"); numprocs != nil { config.Numprocs = numprocs.Value() } - _ = getProcessStatus(&config) + _ = getProcessStatus(&config, containerName) result = append(result, config) } } return result, nil } +func (h *HostToolService) GetSupervisorProcessConfig() ([]response.SupervisorProcessConfig, error) { + configDir := path.Join(global.CONF.System.BaseDir, "1panel", "tools", "supervisord", "supervisor.d") + return handleProcessConfig(configDir, "") +} + func (h *HostToolService) OperateSupervisorProcessFile(req request.SupervisorProcessFileReq) (string, error) { + var ( + includeDir = path.Join(global.CONF.System.BaseDir, "1panel", "tools", "supervisord", "supervisor.d") + ) + return handleSupervisorFile(req, includeDir, "", "") +} + +func handleSupervisorFile(req request.SupervisorProcessFileReq, includeDir, containerName, logFile string) (string, error) { var ( fileOp = files.NewFileOp() group = fmt.Sprintf("program:%s", req.Name) - configPath = path.Join(global.CONF.System.BaseDir, "1panel", "tools", "supervisord", "supervisor.d", fmt.Sprintf("%s.ini", req.Name)) + configPath = path.Join(includeDir, fmt.Sprintf("%s.ini", req.Name)) + err error ) switch req.File { case "err.log": - logPath, err := ini_conf.GetIniValue(configPath, group, "stderr_logfile") - if err != nil { - return "", err + if logFile == "" { + logFile, err = ini_conf.GetIniValue(configPath, group, "stderr_logfile") + if err != nil { + return "", err + } } switch req.Operate { case "get": - content, err := fileOp.GetContent(logPath) + content, err := fileOp.GetContent(logFile) if err != nil { return "", err } return string(content), nil case "clear": - if err = fileOp.WriteFile(logPath, strings.NewReader(""), 0755); err != nil { + if err = fileOp.WriteFile(logFile, strings.NewReader(""), 0755); err != nil { return "", err } } case "out.log": - logPath, err := ini_conf.GetIniValue(configPath, group, "stdout_logfile") - if err != nil { - return "", err + if logFile == "" { + logFile, err = ini_conf.GetIniValue(configPath, group, "stdout_logfile") + if err != nil { + return "", err + } } switch req.Operate { case "get": - content, err := fileOp.GetContent(logPath) + content, err := fileOp.GetContent(logFile) if err != nil { return "", err } return string(content), nil case "clear": - if err = fileOp.WriteFile(logPath, strings.NewReader(""), 0755); err != nil { + if err = fileOp.WriteFile(logFile, strings.NewReader(""), 0755); err != nil { return "", err } } @@ -475,17 +506,16 @@ func (h *HostToolService) OperateSupervisorProcessFile(req request.SupervisorPro if err := fileOp.WriteFile(configPath, strings.NewReader(req.Content), 0755); err != nil { return "", err } - return "", operateSupervisorCtl("update", "", req.Name) + return "", operateSupervisorCtl("update", "", req.Name, includeDir, containerName) } } return "", nil } -func operateSupervisorCtl(operate, name, group string) error { +func operateSupervisorCtl(operate, name, group, includeDir, containerName string) error { processNames := []string{operate} if name != "" { - includeDir := path.Join(global.CONF.System.BaseDir, "1panel", "tools", "supervisord", "supervisor.d") f, err := ini.Load(path.Join(includeDir, fmt.Sprintf("%s.ini", name))) if err != nil { return err @@ -507,14 +537,21 @@ func operateSupervisorCtl(operate, name, group string) error { processNames = append(processNames, group) } - output, err := exec.Command("supervisorctl", processNames...).Output() - if err != nil { - if output != nil { - return errors.New(string(output)) - } - return err + var ( + output string + err error + ) + if containerName != "" { + output, err = cmd.ExecWithTimeOut(fmt.Sprintf("docker exec %s supervisorctl %s", containerName, strings.Join(processNames, " ")), 2*time.Second) + } else { + var out []byte + out, err = exec.Command("supervisorctl", processNames...).Output() + output = string(out) } - return nil + if err != nil && output != "" { + return errors.New(output) + } + return err } func getProcessName(name, numprocs string) []string { @@ -539,14 +576,27 @@ func getProcessName(name, numprocs string) []string { return processNames } -func getProcessStatus(config *response.SupervisorProcessConfig) error { +func getProcessStatus(config *response.SupervisorProcessConfig, containerName string) error { var ( processNames = []string{"status"} + output string + err error ) processNames = append(processNames, getProcessName(config.Name, config.Numprocs)...) - output, _ := exec.Command("supervisorctl", processNames...).Output() - lines := strings.Split(string(output), "\n") + if containerName != "" { + execStr := fmt.Sprintf("docker exec %s supervisorctl %s", containerName, strings.Join(processNames, " ")) + output, err = cmd.ExecWithTimeOut(execStr, 3*time.Second) + } else { + var out []byte + out, err = exec.Command("supervisorctl", processNames...).Output() + output = string(out) + } + if containerName == "" && err != nil { + return err + } + lines := strings.Split(output, "\n") for _, line := range lines { + line = strings.TrimPrefix(line, "stdout:") fields := strings.Fields(line) if len(fields) >= 5 { status := response.ProcessStatus{ diff --git a/agent/app/service/runtime.go b/agent/app/service/runtime.go index aacfd8306..d60ad3095 100644 --- a/agent/app/service/runtime.go +++ b/agent/app/service/runtime.go @@ -60,6 +60,10 @@ type IRuntimeService interface { GetPHPConfigFile(req request.PHPFileReq) (*response.FileInfo, error) UpdateFPMConfig(req request.FPMConfig) error GetFPMConfig(id uint) (*request.FPMConfig, error) + + GetSupervisorProcess(id uint) ([]response.SupervisorProcessConfig, error) + OperateSupervisorProcess(req request.PHPSupervisorProcessConfig) error + OperateSupervisorProcessFile(req request.PHPSupervisorProcessFileReq) (string, error) } func NewRuntimeService() IRuntimeService { @@ -994,3 +998,32 @@ func (r *RuntimeService) GetFPMConfig(id uint) (*request.FPMConfig, error) { res := &request.FPMConfig{Params: params} return res, nil } + +func (r *RuntimeService) GetSupervisorProcess(id uint) ([]response.SupervisorProcessConfig, error) { + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(id)) + if err != nil { + return nil, err + } + configDir := path.Join(constant.RuntimeDir, "php", runtime.Name, "supervisor", "supervisor.d") + return handleProcessConfig(configDir, runtime.ContainerName) +} + +func (r *RuntimeService) OperateSupervisorProcess(req request.PHPSupervisorProcessConfig) error { + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID)) + if err != nil { + return err + } + configDir := path.Join(constant.RuntimeDir, "php", runtime.Name, "supervisor") + return handleProcess(configDir, req.SupervisorProcessConfig, runtime.ContainerName) +} + +func (r *RuntimeService) OperateSupervisorProcessFile(req request.PHPSupervisorProcessFileReq) (string, error) { + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID)) + if err != nil { + return "", err + } + supervisorDir := path.Join(constant.RuntimeDir, "php", runtime.Name, "supervisor") + configDir := path.Join(supervisorDir, "supervisor.d") + logFile := path.Join(supervisorDir, "log", fmt.Sprintf("%s.out.log", req.SupervisorProcessFileReq.Name)) + return handleSupervisorFile(req.SupervisorProcessFileReq, configDir, runtime.ContainerName, logFile) +} diff --git a/agent/app/service/website.go b/agent/app/service/website.go index 6fdf496c8..e9c84adb6 100644 --- a/agent/app/service/website.go +++ b/agent/app/service/website.go @@ -1344,6 +1344,7 @@ func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error server := servers[0] if req.RuntimeID > 0 { + server.RemoveDirective("location", []string{"~", "[^/]\\.php(/|$)"}) runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.RuntimeID)) if err != nil { return err @@ -1462,11 +1463,7 @@ func (w WebsiteService) UpdateSitePermission(req request.WebsiteUpdateDirPermiss if err != nil { return err } - nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) - if err != nil { - return err - } - absoluteIndexPath := path.Join(nginxInstall.GetPath(), "www", "sites", website.Alias, "index") + absoluteIndexPath := GetSitePath(website, SiteIndexDir) chownCmd := fmt.Sprintf("chown -R %s:%s %s", req.User, req.Group, absoluteIndexPath) if cmd.HasNoPasswordSudo() { chownCmd = fmt.Sprintf("sudo %s", chownCmd) diff --git a/agent/router/ro_runtime.go b/agent/router/ro_runtime.go index 1131039b9..dcb9403b7 100644 --- a/agent/router/ro_runtime.go +++ b/agent/router/ro_runtime.go @@ -41,5 +41,9 @@ func (r *RuntimeRouter) InitRouter(Router *gin.RouterGroup) { groupRouter.POST("/php/file", baseApi.GetPHPConfigFile) groupRouter.POST("/php/fpm/config", baseApi.UpdateFPMConfig) groupRouter.GET("/php/fpm/config/:id", baseApi.GetFPMConfig) + + groupRouter.GET("/supervisor/process/:id", baseApi.GetSupervisorProcess) + groupRouter.POST("/supervisor/process", baseApi.OperateSupervisorProcess) + groupRouter.POST("/supervisor/process/file", baseApi.OperateSupervisorProcessFile) } } diff --git a/frontend/src/api/interface/runtime.ts b/frontend/src/api/interface/runtime.ts index 39f52c608..b605dbd09 100644 --- a/frontend/src/api/interface/runtime.ts +++ b/frontend/src/api/interface/runtime.ts @@ -171,4 +171,28 @@ export namespace Runtime { id: number; params: any; } + + export interface ProcessReq { + operate: string; + name: string; + id: number; + } + + export interface ProcessFileReq { + operate: string; + name: string; + content?: string; + file: string; + id: number; + } + + export interface SupersivorProcess { + operate: string; + name: string; + command: string; + user: string; + dir: string; + numprocs: string; + id: number; + } } diff --git a/frontend/src/api/modules/runtime.ts b/frontend/src/api/modules/runtime.ts index a3da6dac7..b4f9eb5a4 100644 --- a/frontend/src/api/modules/runtime.ts +++ b/frontend/src/api/modules/runtime.ts @@ -4,6 +4,7 @@ import { Runtime } from '../interface/runtime'; import { TimeoutEnum } from '@/enums/http-enum'; import { App } from '@/api/interface/app'; import { File } from '../interface/file'; +import { HostTool } from '../interface/host-tool'; export const SearchRuntimes = (req: Runtime.RuntimeReq) => { return http.post>(`/runtimes/search`, req); @@ -104,3 +105,19 @@ export const UpdateFPMConfig = (req: Runtime.FPMConfig) => { export const GetFPMConfig = (id: number) => { return http.get(`/runtimes/php/fpm/config/${id}`); }; + +export const GetSupervisorProcess = (id: number) => { + return http.get(`/runtimes/supervisor/process/${id}`); +}; + +export const OperateSupervisorProcess = (req: Runtime.ProcessReq) => { + return http.post(`/runtimes/supervisor/process`, req, TimeoutEnum.T_60S); +}; + +export const OperateSupervisorProcessFile = (req: Runtime.ProcessFileReq) => { + return http.post(`/runtimes/supervisor/process/file`, req, TimeoutEnum.T_60S); +}; + +export const CreateSupervisorProcess = (req: Runtime.SupersivorProcess) => { + return http.post(`/runtimes/supervisor/process`, req); +}; diff --git a/frontend/src/components/drawer-pro/index.vue b/frontend/src/components/drawer-pro/index.vue index 2df89f107..fcb6a523f 100644 --- a/frontend/src/components/drawer-pro/index.vue +++ b/frontend/src/components/drawer-pro/index.vue @@ -85,6 +85,8 @@ const size = computed(() => { return '50%'; case 'full': return '100%'; + case '60%': + return '60%'; default: return '50%'; } diff --git a/frontend/src/views/website/runtime/php/index.vue b/frontend/src/views/website/runtime/php/index.vue index 3f2818452..29c09608b 100644 --- a/frontend/src/views/website/runtime/php/index.vue +++ b/frontend/src/views/website/runtime/php/index.vue @@ -112,6 +112,7 @@ + @@ -133,6 +134,7 @@ import RouterMenu from '../index.vue'; import Log from '@/components/log-dialog/index.vue'; import ComposeLogs from '@/components/compose-log/index.vue'; import Config from '@/views/website/runtime/php/config/index.vue'; +import Supervisor from '@/views/website/runtime/php/supervisor/index.vue'; const paginationConfig = reactive({ cacheSizeKey: 'runtime-page-size', @@ -157,6 +159,7 @@ const loading = ref(false); const items = ref([]); const composeLogRef = ref(); const configRef = ref(); +const supervisorRef = ref(); const buttons = [ { @@ -218,6 +221,15 @@ const buttons = [ return row.status === 'building'; }, }, + { + label: i18n.global.t('menu.supervisor'), + click: function (row: Runtime.Runtime) { + openSupervisor(row); + }, + disabled: function (row: Runtime.Runtime) { + return row.status === 'building'; + }, + }, { label: i18n.global.t('commons.button.delete'), disabled: function (row: Runtime.Runtime) { @@ -255,6 +267,10 @@ const openConfig = (row: Runtime.Runtime) => { configRef.value.acceptParams(row); }; +const openSupervisor = (row: Runtime.Runtime) => { + supervisorRef.value.acceptParams(row.id); +}; + const openLog = (row: Runtime.RuntimeDTO) => { if (row.status == 'running') { composeLogRef.value.acceptParams({ compose: row.path + '/docker-compose.yml', resource: row.name }); @@ -344,7 +360,7 @@ onMounted(() => { search(); timer = setInterval(() => { search(); - }, 10000 * 3); + }, 10000 * 1); }); onUnmounted(() => { diff --git a/frontend/src/views/website/runtime/php/supervisor/create/index.vue b/frontend/src/views/website/runtime/php/supervisor/create/index.vue new file mode 100644 index 000000000..2470d52a7 --- /dev/null +++ b/frontend/src/views/website/runtime/php/supervisor/create/index.vue @@ -0,0 +1,133 @@ + + + diff --git a/frontend/src/views/website/runtime/php/supervisor/file/index.vue b/frontend/src/views/website/runtime/php/supervisor/file/index.vue new file mode 100644 index 000000000..850143763 --- /dev/null +++ b/frontend/src/views/website/runtime/php/supervisor/file/index.vue @@ -0,0 +1,148 @@ + + + + diff --git a/frontend/src/views/website/runtime/php/supervisor/index.vue b/frontend/src/views/website/runtime/php/supervisor/index.vue new file mode 100644 index 000000000..b0a81ab49 --- /dev/null +++ b/frontend/src/views/website/runtime/php/supervisor/index.vue @@ -0,0 +1,316 @@ + + + diff --git a/frontend/src/views/website/website/config/basic/index.vue b/frontend/src/views/website/website/config/basic/index.vue index c57b808da..16230ed09 100644 --- a/frontend/src/views/website/website/config/basic/index.vue +++ b/frontend/src/views/website/website/config/basic/index.vue @@ -43,7 +43,7 @@ :label="'PHP'" v-if="(website.type === 'runtime' && website.runtimeType === 'php') || website.type === 'static'" > - + diff --git a/frontend/src/views/website/website/nginx/module/build/index.vue b/frontend/src/views/website/website/nginx/module/build/index.vue index a7d150a7d..c2e988050 100644 --- a/frontend/src/views/website/website/nginx/module/build/index.vue +++ b/frontend/src/views/website/website/nginx/module/build/index.vue @@ -76,6 +76,7 @@ const submit = async (form: FormInstance) => { taskID: taskID, mirror: build.value.mirror, }); + handleClose(); openTaskLog(taskID); } catch (error) {} });