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