mirror of
				https://github.com/1Panel-dev/1Panel.git
				synced 2025-10-31 03:07:34 +08:00 
			
		
		
		
	
							parent
							
								
									c3134e4c2a
								
							
						
					
					
						commit
						e67d9055aa
					
				
					 6 changed files with 34 additions and 21 deletions
				
			
		|  | @ -196,7 +196,12 @@ func (b *BaseApi) GetProcess(c *gin.Context) { | |||
| // @Security ApiKeyAuth | ||||
| // @Router /host/tool/supervisor/process/load [post] | ||||
| func (b *BaseApi) LoadProcessStatus(c *gin.Context) { | ||||
| 	helper.SuccessWithData(c, hostToolService.LoadProcessStatus()) | ||||
| 	datas, err := hostToolService.LoadProcessStatus() | ||||
| 	if err != nil { | ||||
| 		helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) | ||||
| 		return | ||||
| 	} | ||||
| 	helper.SuccessWithData(c, datas) | ||||
| } | ||||
| 
 | ||||
| // @Tags Host tool | ||||
|  |  | |||
|  | @ -34,7 +34,7 @@ type IHostToolService interface { | |||
| 	GetToolLog(req request.HostToolLogReq) (string, error) | ||||
| 	OperateSupervisorProcess(req request.SupervisorProcessConfig) error | ||||
| 	GetSupervisorProcessConfig() ([]response.SupervisorProcessConfig, error) | ||||
| 	LoadProcessStatus() []response.ProcessStatus | ||||
| 	LoadProcessStatus() ([]response.ProcessStatus, error) | ||||
| 	OperateSupervisorProcessFile(req request.SupervisorProcessFileReq) (string, error) | ||||
| } | ||||
| 
 | ||||
|  | @ -377,11 +377,11 @@ func (h *HostToolService) OperateSupervisorProcess(req request.SupervisorProcess | |||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (h *HostToolService) LoadProcessStatus() []response.ProcessStatus { | ||||
| func (h *HostToolService) LoadProcessStatus() ([]response.ProcessStatus, error) { | ||||
| 	var datas []response.ProcessStatus | ||||
| 	statuLines, err := cmd.Exec("supervisorctl status") | ||||
| 	statuLines, err := cmd.Exec("supervisorct status") | ||||
| 	if err != nil { | ||||
| 		return datas | ||||
| 		return datas, fmt.Errorf("exec `supervisorctl status` failed, err: %v", statuLines) | ||||
| 	} | ||||
| 	lines := strings.Split(string(statuLines), "\n") | ||||
| 	for _, line := range lines { | ||||
|  | @ -424,7 +424,7 @@ func (h *HostToolService) LoadProcessStatus() []response.ProcessStatus { | |||
| 		}(i) | ||||
| 	} | ||||
| 	wg.Wait() | ||||
| 	return datas | ||||
| 	return datas, nil | ||||
| } | ||||
| 
 | ||||
| func (h *HostToolService) GetSupervisorProcessConfig() ([]response.SupervisorProcessConfig, error) { | ||||
|  |  | |||
|  | @ -1666,6 +1666,7 @@ const message = { | |||
|     }, | ||||
|     tool: { | ||||
|         supervisor: { | ||||
|             loadStatusErr: 'Failed to retrieve process status, please check the status of the supervisor service.', | ||||
|             notSupport: 'Supervisor is not detected, please refer to the official document for installation', | ||||
|             list: 'Daemon process', | ||||
|             config: 'Supervisor configuration', | ||||
|  |  | |||
|  | @ -1580,6 +1580,7 @@ const message = { | |||
|     }, | ||||
|     tool: { | ||||
|         supervisor: { | ||||
|             loadStatusErr: '獲取進程狀態失敗,請檢查 supervisor 服務狀態', | ||||
|             notSupport: '未檢測到 Supervisor,請參考官方文檔進行安裝', | ||||
|             list: '守護進程', | ||||
|             config: 'Supervisor 配置', | ||||
|  |  | |||
|  | @ -1582,6 +1582,7 @@ const message = { | |||
|     }, | ||||
|     tool: { | ||||
|         supervisor: { | ||||
|             loadStatusErr: '获取进程状态失败,请检查 supervisor 服务状态', | ||||
|             notSupport: '未检测到 Supervisor,请参考官方文档进行安装', | ||||
|             list: '守护进程', | ||||
|             config: 'Supervisor 配置', | ||||
|  |  | |||
|  | @ -221,22 +221,27 @@ const search = async () => { | |||
| }; | ||||
| 
 | ||||
| const loadStatus = async () => { | ||||
|     const res = await LoadProcessStatus(); | ||||
|     let stats = res.data || []; | ||||
|     if (stats.length === 0) { | ||||
|         return; | ||||
|     } | ||||
|     for (const process of data.value) { | ||||
|         process.status = []; | ||||
|         for (const item of stats) { | ||||
|             if (process.name === item.name.split(':')[0]) { | ||||
|                 process.status.push(item); | ||||
|     await LoadProcessStatus() | ||||
|         .then((res) => { | ||||
|             let stats = res.data || []; | ||||
|             for (const process of data.value) { | ||||
|                 process.status = []; | ||||
|                 for (const item of stats) { | ||||
|                     if (process.name === item.name.split(':')[0]) { | ||||
|                         process.status.push(item); | ||||
|                     } | ||||
|                 } | ||||
|                 if (process.status.length !== 0) { | ||||
|                     process.hasLoad = true; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (process.status.length !== 0) { | ||||
|             process.hasLoad = true; | ||||
|         } | ||||
|     } | ||||
|         }) | ||||
|         .catch(() => { | ||||
|             for (const process of data.value) { | ||||
|                 process.status = [{ name: '-', status: 'FATAL', msg: i18n.global.t('tool.supervisor.loadStatusErr') }]; | ||||
|                 process.hasLoad = true; | ||||
|             } | ||||
|         }); | ||||
| }; | ||||
| 
 | ||||
| const mobile = computed(() => { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue