mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
parent
fe7fed02ee
commit
24c87905b1
@ -531,11 +531,15 @@ func (u *ContainerService) ContainerLogClean(req dto.OperationWithName) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container, err := client.ContainerInspect(context.Background(), req.Name)
|
ctx := context.Background()
|
||||||
|
containerItem, err := client.ContainerInspect(ctx, req.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
file, err := os.OpenFile(container.LogPath, os.O_RDWR|os.O_CREATE, 0666)
|
if err := client.ContainerStop(ctx, containerItem.ID, container.StopOptions{}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
file, err := os.OpenFile(containerItem.LogPath, os.O_RDWR|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -545,10 +549,14 @@ func (u *ContainerService) ContainerLogClean(req dto.OperationWithName) error {
|
|||||||
}
|
}
|
||||||
_, _ = file.Seek(0, 0)
|
_, _ = file.Seek(0, 0)
|
||||||
|
|
||||||
files, _ := filepath.Glob(fmt.Sprintf("%s.*", container.LogPath))
|
files, _ := filepath.Glob(fmt.Sprintf("%s.*", containerItem.LogPath))
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
_ = os.Remove(file)
|
_ = os.Remove(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := client.ContainerStart(ctx, containerItem.ID, types.ContainerStartOptions{}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ const acceptParams = (props: DialogProps): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onClean = async () => {
|
const onClean = async () => {
|
||||||
ElMessageBox.confirm(i18n.global.t('commons.msg.clean'), i18n.global.t('container.cleanLog'), {
|
ElMessageBox.confirm(i18n.global.t('container.cleanLogHelper'), i18n.global.t('container.cleanLog'), {
|
||||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
||||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||||
type: 'info',
|
type: 'info',
|
||||||
|
@ -507,6 +507,8 @@ const message = {
|
|||||||
lastHour: 'Last Hour',
|
lastHour: 'Last Hour',
|
||||||
last10Min: 'Last 10 Minutes',
|
last10Min: 'Last 10 Minutes',
|
||||||
cleanLog: 'Clean log',
|
cleanLog: 'Clean log',
|
||||||
|
cleanLogHelper:
|
||||||
|
'Clearing logs requires restarting the container, and this operation cannot be rolled back. Do you want to continue?',
|
||||||
newName: 'New name',
|
newName: 'New name',
|
||||||
source: 'Resource rate',
|
source: 'Resource rate',
|
||||||
cpuShare: 'CPU Share',
|
cpuShare: 'CPU Share',
|
||||||
|
@ -496,6 +496,7 @@ const message = {
|
|||||||
lastHour: '最近 1 小時',
|
lastHour: '最近 1 小時',
|
||||||
last10Min: '最近 10 分鐘',
|
last10Min: '最近 10 分鐘',
|
||||||
cleanLog: '清空日誌',
|
cleanLog: '清空日誌',
|
||||||
|
cleanLogHelper: '清空日誌需要重啟容器,該操作無法回滾,是否繼續?',
|
||||||
newName: '新名稱',
|
newName: '新名稱',
|
||||||
source: '資源使用率',
|
source: '資源使用率',
|
||||||
cpuShare: 'CPU 權重',
|
cpuShare: 'CPU 權重',
|
||||||
|
@ -496,6 +496,7 @@ const message = {
|
|||||||
lastHour: '最近 1 小时',
|
lastHour: '最近 1 小时',
|
||||||
last10Min: '最近 10 分钟',
|
last10Min: '最近 10 分钟',
|
||||||
cleanLog: '清空日志',
|
cleanLog: '清空日志',
|
||||||
|
cleanLogHelper: '清空日志需要重启容器,该操作无法回滚,是否继续?',
|
||||||
newName: '新名称',
|
newName: '新名称',
|
||||||
source: '资源使用率',
|
source: '资源使用率',
|
||||||
cpuShare: 'CPU 权重',
|
cpuShare: 'CPU 权重',
|
||||||
|
@ -161,7 +161,7 @@ const onDownload = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onClean = async () => {
|
const onClean = async () => {
|
||||||
ElMessageBox.confirm(i18n.global.t('commons.msg.clean'), i18n.global.t('container.cleanLog'), {
|
ElMessageBox.confirm(i18n.global.t('container.cleanLogHelper'), i18n.global.t('container.cleanLog'), {
|
||||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
||||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||||
type: 'info',
|
type: 'info',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user