mirror of https://github.com/1Panel-dev/1Panel
fix: docker 关闭增加 socket、service 选项
parent
c4e54b2f0f
commit
c86822fd3d
|
@ -14,5 +14,7 @@ type DaemonJsonConf struct {
|
|||
}
|
||||
|
||||
type DockerOperation struct {
|
||||
Operation string `json:"operation" validate:"required,oneof=start restart stop"`
|
||||
StopSocket bool `json:"stopSocket"`
|
||||
StopService bool `json:"stopService"`
|
||||
Operation string `json:"operation" validate:"required,oneof=start restart stop"`
|
||||
}
|
||||
|
|
|
@ -180,7 +180,14 @@ func (u *DockerService) UpdateConfByFile(req dto.DaemonJsonUpdateByFile) error {
|
|||
}
|
||||
|
||||
func (u *DockerService) OperateDocker(req dto.DockerOperation) error {
|
||||
stdout, err := cmd.Execf("systemctl %s docker ", req.Operation)
|
||||
service := "docker"
|
||||
if req.Operation == "stop" {
|
||||
service = "docker.service"
|
||||
if req.StopSocket {
|
||||
service = "docker.socket"
|
||||
}
|
||||
}
|
||||
stdout, err := cmd.Execf("systemctl %s %s ", req.Operation, service)
|
||||
if err != nil {
|
||||
return errors.New(string(stdout))
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ declare module 'vue' {
|
|||
ContainerLog: typeof import('./src/components/container-log/index.vue')['default']
|
||||
DrawerHeader: typeof import('./src/components/drawer-header/index.vue')['default']
|
||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||
ElAlter: typeof import('element-plus/es')['ElAlter']
|
||||
ElAside: typeof import('element-plus/es')['ElAside']
|
||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||
ElBadge: typeof import('element-plus/es')['ElBadge']
|
||||
|
|
|
@ -241,6 +241,8 @@ export namespace Container {
|
|||
file: string;
|
||||
}
|
||||
export interface DockerOperate {
|
||||
stopSocket: boolean;
|
||||
stopService: boolean;
|
||||
operation: string;
|
||||
}
|
||||
export interface DaemonJsonConf {
|
||||
|
|
|
@ -529,6 +529,10 @@ export default {
|
|||
composeOperatorHelper: '{1} operation will be performed on {0}. Do you want to continue?',
|
||||
|
||||
setting: 'Setting',
|
||||
stopHelper: 'docker service includes docker.service and docker.socket: ',
|
||||
stopHelper2:
|
||||
'When docker.service is stopped, Docker.socket will keep listening state. When docker command request is listened, The docker.service will be pulled up again.',
|
||||
stopHelper3: 'Stopping docker.socket will make the docker.service service unavailable',
|
||||
dockerStatus: 'Docker Service',
|
||||
daemonJsonPathHelper: 'Ensure that the configuration path is the same as that specified in docker.service.',
|
||||
mirrors: 'Registry mirrors',
|
||||
|
|
|
@ -541,6 +541,10 @@ export default {
|
|||
composeOperatorHelper: '将对 {0} 进行 {1} 操作,是否继续?',
|
||||
|
||||
setting: '配置',
|
||||
stopHelper: 'docker 服务包括 docker.service 和 docker.socket 两部分: ',
|
||||
stopHelper2:
|
||||
'停止 docker.service 时 docker.socket 将保持监听状态,当监听到 docker 命令请求时,会将 docker.service 重新拉起。',
|
||||
stopHelper3: '停止 docker.socket 将导致 docker.service 服务不可用',
|
||||
dockerStatus: 'Docker 服务',
|
||||
daemonJsonPathHelper: '请保证配置路径与 docker.service 中指定的配置路径保持一致。',
|
||||
mirrors: '镜像加速',
|
||||
|
|
|
@ -102,6 +102,24 @@
|
|||
</template>
|
||||
</LayoutContent>
|
||||
|
||||
<el-dialog v-model="stopVisiable" :title="$t('app.checkTitle')" width="50%" :destroy-on-close="true">
|
||||
<el-alert :closable="false">
|
||||
{{ $t('container.stopHelper') }}
|
||||
<li>{{ $t('container.stopHelper2') }}</li>
|
||||
<li>{{ $t('container.stopHelper3') }}</li>
|
||||
</el-alert>
|
||||
<div style="margin-top: 10px">
|
||||
<el-checkbox v-model="stopService" label="docker.service" />
|
||||
</div>
|
||||
<div class="stopCheckbox"><el-checkbox v-model="stopSocket" label="docker.socket" /></div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="stopVisiable = false">{{ $t('commons.button.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submitStop">{{ $t('commons.button.confirm') }}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<ConfirmDialog ref="confirmDialogRef" @confirm="onSubmitSave"></ConfirmDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -142,6 +160,10 @@ const formRef = ref<FormInstance>();
|
|||
const dockerConf = ref();
|
||||
const confirmDialogRef = ref();
|
||||
|
||||
const stopVisiable = ref();
|
||||
const stopSocket = ref();
|
||||
const stopService = ref();
|
||||
|
||||
const onSave = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.validate(async (valid) => {
|
||||
|
@ -165,7 +187,13 @@ const onSaveFile = async () => {
|
|||
};
|
||||
|
||||
const onOperator = async (operation: string) => {
|
||||
if (operation === 'stop') {
|
||||
stopVisiable.value = true;
|
||||
return;
|
||||
}
|
||||
let param = {
|
||||
stopService: false,
|
||||
stopSocket: false,
|
||||
operation: operation,
|
||||
};
|
||||
loading.value = true;
|
||||
|
@ -181,6 +209,25 @@ const onOperator = async (operation: string) => {
|
|||
});
|
||||
};
|
||||
|
||||
const submitStop = async () => {
|
||||
let param = {
|
||||
stopService: stopService.value,
|
||||
stopSocket: stopSocket.value,
|
||||
operation: 'stop',
|
||||
};
|
||||
loading.value = true;
|
||||
await dockerOperate(param)
|
||||
.then(() => {
|
||||
loading.value = false;
|
||||
search();
|
||||
changeMode();
|
||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const onSubmitSave = async () => {
|
||||
if (confShowType.value === 'all') {
|
||||
let param = { file: dockerConf.value };
|
||||
|
|
Loading…
Reference in New Issue