功能优化

main
阳光少年 1 year ago
parent 1ce1237076
commit 2f30d2b1bc

@ -477,7 +477,7 @@ fn stop_container(containers_id: &str, is_remove: bool) -> Result<()> {
let container_merged_path = container_work_path.join("merged");
// 正在运行中的需要 kill
if container_info.status == ContainerStatus::RUNNING {
kill(Pid::from_raw(container_info.pid), Signal::SIGTERM)?;
let _ = kill(Pid::from_raw(container_info.pid), Signal::SIGTERM);
}
// 卸载自定义挂载点
if container_info.volume != "" {
@ -487,14 +487,14 @@ fn stop_container(containers_id: &str, is_remove: bool) -> Result<()> {
.map(|v| container_merged_path.join(v).to_string_lossy().to_string())
.for_each(|s| {
match umount(s.as_str()) {
Ok(s) => println!("卸载自定卷: {s:?}"),
Ok(_) => println!("卸载自定卷"),
Err(e) => panic!("卸载卷失败: {e:?}"),
}
});
}
// 卸载overlayfs
match umount(container_merged_path.to_str().unwrap()) {
Ok(s) => println!("卸载overlayfs卷: {s:?}"),
Ok(_) => println!("卸载overlayfs卷"),
Err(e) => println!("卸载overlayfs失败: {e:?}"),
}
@ -502,7 +502,7 @@ fn stop_container(containers_id: &str, is_remove: bool) -> Result<()> {
// 删除容器目录
if is_remove {
match fs::remove_dir_all(container_work_path) {
Ok(s) => println!("删除容器 {container_id} 成功"),
Ok(_) => println!("删除容器 {container_id} 成功"),
Err(e) => println!("删除容器失败: {e:?}"),
}
}

Loading…
Cancel
Save