fix: 解决进程状态一直加载中的问题 (#1983)

Refs #1968
release-1.5
ssongliu 1 year ago committed by wanghe-fit2cloud
parent 06f81fc7f7
commit 62d628c1aa

@ -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,11 +221,9 @@ const search = async () => {
};
const loadStatus = async () => {
const res = await LoadProcessStatus();
await LoadProcessStatus()
.then((res) => {
let stats = res.data || [];
if (stats.length === 0) {
return;
}
for (const process of data.value) {
process.status = [];
for (const item of stats) {
@ -237,6 +235,13 @@ const loadStatus = async () => {
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…
Cancel
Save