Skip to content

Commit af15d00

Browse files
feat: 处理 1Panel 重启导致运行环境状态异常的问题
1 parent 05029a3 commit af15d00

File tree

8 files changed

+40
-2
lines changed

8 files changed

+40
-2
lines changed

backend/app/service/runtime.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type IRuntimeService interface {
4040
OperateRuntime(req request.RuntimeOperate) error
4141
GetNodeModules(req request.NodeModuleReq) ([]response.NodeModule, error)
4242
OperateNodeModules(req request.NodeModuleOperateReq) error
43+
SyncForRestart() error
4344
}
4445

4546
func NewRuntimeService() IRuntimeService {
@@ -555,3 +556,18 @@ func (r *RuntimeService) OperateNodeModules(req request.NodeModuleOperateReq) er
555556
cmd += " " + req.Module
556557
return cmd2.ExecContainerScript(containerName, cmd, 5*time.Minute)
557558
}
559+
560+
func (r *RuntimeService) SyncForRestart() error {
561+
runtimes, err := runtimeRepo.List()
562+
if err != nil {
563+
return err
564+
}
565+
for _, runtime := range runtimes {
566+
if runtime.Status == constant.RuntimeBuildIng || runtime.Status == constant.RuntimeReCreating || runtime.Status == constant.RuntimeStarting || runtime.Status == constant.RuntimeCreating {
567+
runtime.Status = constant.SystemRestart
568+
runtime.Message = "System restart causing interrupt"
569+
_ = runtimeRepo.Save(&runtime)
570+
}
571+
}
572+
return nil
573+
}

backend/constant/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ type DBContext string
44

55
const (
66
DB DBContext = "db"
7+
8+
SystemRestart = "systemRestart"
79
)

backend/init/business/business.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
func Init() {
99
go syncApp()
1010
go syncInstalledApp()
11+
go syncRuntime()
1112
}
1213

1314
func syncApp() {
@@ -22,3 +23,9 @@ func syncInstalledApp() {
2223
global.LOG.Errorf("sync instaled app error: %s", err.Error())
2324
}
2425
}
26+
27+
func syncRuntime() {
28+
if err := service.NewRuntimeService().SyncForRestart(); err != nil {
29+
global.LOG.Errorf("sync runtime status error : %s", err.Error())
30+
}
31+
}

backend/utils/ssl/acme_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func TestAppToV2(t *testing.T) {
144144
}
145145
_ = fileOp.DeleteFile(newVersionDir + "/config.json")
146146
oldReadMefile := newVersionDir + "/README.md"
147-
_ = fileOp.Cut([]string{oldReadMefile}, newAppDir)
147+
_ = fileOp.Cut([]string{oldReadMefile}, newAppDir, "", false)
148148
_ = fileOp.DeleteFile(oldReadMefile)
149149
}
150150
}

frontend/src/lang/modules/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ const message = {
234234
starting: 'Starting',
235235
recreating: 'Recreating',
236236
creating: 'Creating',
237+
systemrestart: 'Interrupt',
237238
},
238239
units: {
239240
second: 'Second',
@@ -1842,6 +1843,7 @@ const message = {
18421843
customScript: 'Custom startup command',
18431844
customScriptHelper: 'Please fill in the complete startup command, for example: npm run start',
18441845
portError: 'Cannot fill in the same port',
1846+
systemRestartHelper: 'Status description: Interruption - status acquisition failed due to system restart',
18451847
},
18461848
process: {
18471849
pid: 'Process ID',

frontend/src/lang/modules/tw.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ const message = {
233233
starting: '啟動中',
234234
recreating: '重建中',
235235
creating: '創建中',
236+
systemrestart: '中斷',
236237
},
237238
units: {
238239
second: '秒',
@@ -1738,6 +1739,7 @@ const message = {
17381739
customScript: '自訂啟動指令',
17391740
customScriptHelper: '請填寫完整的啟動指令,例如:npm run start',
17401741
portError: '不能填寫相同連接埠',
1742+
systemRestartHelper: '狀態說明:中斷-系統重新啟動導致狀態取得失敗',
17411743
},
17421744
process: {
17431745
pid: '進程ID',

frontend/src/lang/modules/zh.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ const message = {
233233
starting: '启动中',
234234
recreating: '重建中',
235235
creating: '创建中',
236+
systemrestart: '中断',
236237
},
237238
units: {
238239
second: '秒',
@@ -1738,6 +1739,7 @@ const message = {
17381739
customScript: '自定义启动命令',
17391740
customScriptHelper: '请填写完整的启动命令,例如:npm run start',
17401741
portError: '不能填写相同端口',
1742+
systemRestartHelper: '状态说明:中断-系统重启导致状态获取失败',
17411743
},
17421744
process: {
17431745
pid: '进程ID',

frontend/src/views/website/runtime/php/index.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<div>
33
<RouterMenu />
44
<LayoutContent :title="'PHP'" v-loading="loading">
5+
<template #prompt>
6+
<el-alert type="info" :closable="false">
7+
<template #default>
8+
<span><span v-html="$t('runtime.systemRestartHelper')"></span></span>
9+
</template>
10+
</el-alert>
11+
</template>
512
<template #toolbar>
613
<el-button type="primary" @click="openCreate">
714
{{ $t('runtime.create') }}
@@ -24,7 +31,7 @@
2431
<el-table-column :label="$t('commons.table.status')" prop="status">
2532
<template #default="{ row }">
2633
<el-popover
27-
v-if="row.status === 'error'"
34+
v-if="row.status === 'error' || row.status === 'systemRestart'"
2835
placement="bottom"
2936
:width="400"
3037
trigger="hover"

0 commit comments

Comments
 (0)