diff --git a/daemon/src/entity/commands/docker/docker_start.ts b/daemon/src/entity/commands/docker/docker_start.ts index 9d012af7..716a4cd8 100755 --- a/daemon/src/entity/commands/docker/docker_start.ts +++ b/daemon/src/entity/commands/docker/docker_start.ts @@ -74,7 +74,9 @@ export class DockerProcessAdapter extends EventEmitter implements IInstanceProce } public async destroy() { - await this.container.remove(); + try { + await this.container.remove(); + } catch (error) {} } private wait() { diff --git a/daemon/src/service/system_instance.ts b/daemon/src/service/system_instance.ts index e95db29a..e5f32630 100755 --- a/daemon/src/service/system_instance.ts +++ b/daemon/src/service/system_instance.ts @@ -174,17 +174,16 @@ class InstanceSubsystem extends EventEmitter { removeInstance(instanceUuid: string, deleteFile: boolean) { const instance = this.getInstance(instanceUuid); if (instance) { + if (instance.status() !== Instance.STATUS_STOP) + throw new Error($t("请确保实例处于停止状态再删除!")); instance.destroy(); - // destroy record this.instances.delete(instanceUuid); StorageSubsystem.delete("InstanceConfig", instanceUuid); - // delete scheduled task InstanceControl.deleteInstanceAllTask(instanceUuid); - // delete the file asynchronously if (deleteFile) fs.remove(instance.config.cwd, (err) => {}); return true; } - throw new Error("Instance does not exist"); + throw new Error($t("目标实例不存在!")); } forward(targetInstanceUuid: string, socket: Socket) {