mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
feat: 处理 1Panel 重启导致运行环境状态异常的问题 (#2773)
This commit is contained in:
parent
2d8a7bbbc3
commit
47b75673f9
@ -40,6 +40,7 @@ type IRuntimeService interface {
|
||||
OperateRuntime(req request.RuntimeOperate) error
|
||||
GetNodeModules(req request.NodeModuleReq) ([]response.NodeModule, error)
|
||||
OperateNodeModules(req request.NodeModuleOperateReq) error
|
||||
SyncForRestart() error
|
||||
}
|
||||
|
||||
func NewRuntimeService() IRuntimeService {
|
||||
@ -555,3 +556,18 @@ func (r *RuntimeService) OperateNodeModules(req request.NodeModuleOperateReq) er
|
||||
cmd += " " + req.Module
|
||||
return cmd2.ExecContainerScript(containerName, cmd, 5*time.Minute)
|
||||
}
|
||||
|
||||
func (r *RuntimeService) SyncForRestart() error {
|
||||
runtimes, err := runtimeRepo.List()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, runtime := range runtimes {
|
||||
if runtime.Status == constant.RuntimeBuildIng || runtime.Status == constant.RuntimeReCreating || runtime.Status == constant.RuntimeStarting || runtime.Status == constant.RuntimeCreating {
|
||||
runtime.Status = constant.SystemRestart
|
||||
runtime.Message = "System restart causing interrupt"
|
||||
_ = runtimeRepo.Save(&runtime)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -4,4 +4,6 @@ type DBContext string
|
||||
|
||||
const (
|
||||
DB DBContext = "db"
|
||||
|
||||
SystemRestart = "systemRestart"
|
||||
)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
func Init() {
|
||||
go syncApp()
|
||||
go syncInstalledApp()
|
||||
go syncRuntime()
|
||||
}
|
||||
|
||||
func syncApp() {
|
||||
@ -22,3 +23,9 @@ func syncInstalledApp() {
|
||||
global.LOG.Errorf("sync instaled app error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func syncRuntime() {
|
||||
if err := service.NewRuntimeService().SyncForRestart(); err != nil {
|
||||
global.LOG.Errorf("sync runtime status error : %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func TestAppToV2(t *testing.T) {
|
||||
}
|
||||
_ = fileOp.DeleteFile(newVersionDir + "/config.json")
|
||||
oldReadMefile := newVersionDir + "/README.md"
|
||||
// _ = fileOp.Cut([]string{oldReadMefile}, newAppDir)
|
||||
_ = fileOp.Cut([]string{oldReadMefile}, newAppDir, "", false)
|
||||
_ = fileOp.DeleteFile(oldReadMefile)
|
||||
}
|
||||
}
|
||||
|
@ -234,6 +234,7 @@ const message = {
|
||||
starting: 'Starting',
|
||||
recreating: 'Recreating',
|
||||
creating: 'Creating',
|
||||
systemrestart: 'Interrupt',
|
||||
},
|
||||
units: {
|
||||
second: 'Second',
|
||||
@ -1842,6 +1843,7 @@ const message = {
|
||||
customScript: 'Custom startup command',
|
||||
customScriptHelper: 'Please fill in the complete startup command, for example: npm run start',
|
||||
portError: 'Cannot fill in the same port',
|
||||
systemRestartHelper: 'Status description: Interruption - status acquisition failed due to system restart',
|
||||
},
|
||||
process: {
|
||||
pid: 'Process ID',
|
||||
|
@ -233,6 +233,7 @@ const message = {
|
||||
starting: '啟動中',
|
||||
recreating: '重建中',
|
||||
creating: '創建中',
|
||||
systemrestart: '中斷',
|
||||
},
|
||||
units: {
|
||||
second: '秒',
|
||||
@ -1738,6 +1739,7 @@ const message = {
|
||||
customScript: '自訂啟動指令',
|
||||
customScriptHelper: '請填寫完整的啟動指令,例如:npm run start',
|
||||
portError: '不能填寫相同連接埠',
|
||||
systemRestartHelper: '狀態說明:中斷-系統重新啟動導致狀態取得失敗',
|
||||
},
|
||||
process: {
|
||||
pid: '進程ID',
|
||||
|
@ -233,6 +233,7 @@ const message = {
|
||||
starting: '启动中',
|
||||
recreating: '重建中',
|
||||
creating: '创建中',
|
||||
systemrestart: '中断',
|
||||
},
|
||||
units: {
|
||||
second: '秒',
|
||||
@ -1738,6 +1739,7 @@ const message = {
|
||||
customScript: '自定义启动命令',
|
||||
customScriptHelper: '请填写完整的启动命令,例如:npm run start',
|
||||
portError: '不能填写相同端口',
|
||||
systemRestartHelper: '状态说明:中断-系统重启导致状态获取失败',
|
||||
},
|
||||
process: {
|
||||
pid: '进程ID',
|
||||
|
@ -2,6 +2,13 @@
|
||||
<div>
|
||||
<RouterMenu />
|
||||
<LayoutContent :title="'PHP'" v-loading="loading">
|
||||
<template #prompt>
|
||||
<el-alert type="info" :closable="false">
|
||||
<template #default>
|
||||
<span>{{ $t('runtime.systemRestartHelper') }}</span>
|
||||
</template>
|
||||
</el-alert>
|
||||
</template>
|
||||
<template #toolbar>
|
||||
<el-button type="primary" @click="openCreate">
|
||||
{{ $t('runtime.create') }}
|
||||
@ -24,7 +31,7 @@
|
||||
<el-table-column :label="$t('commons.table.status')" prop="status">
|
||||
<template #default="{ row }">
|
||||
<el-popover
|
||||
v-if="row.status === 'error'"
|
||||
v-if="row.status === 'error' || row.status === 'systemRestart'"
|
||||
placement="bottom"
|
||||
:width="400"
|
||||
trigger="hover"
|
||||
|
Loading…
x
Reference in New Issue
Block a user