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