Fix: Docker Stop Err

This commit is contained in:
unitwk 2024-03-13 10:53:37 +08:00
parent 90cced1475
commit 16a6235041
2 changed files with 6 additions and 5 deletions

View File

@ -74,7 +74,9 @@ export class DockerProcessAdapter extends EventEmitter implements IInstanceProce
}
public async destroy() {
try {
await this.container.remove();
} catch (error) {}
}
private wait() {

View File

@ -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) {