修复--log导致网络设备被删除

main
阳光少年 1 year ago
parent 174b18ab76
commit 27891e36f6

@ -1,3 +1,4 @@
use std::os::unix::fs::OpenOptionsExt;
use std::{io, fs, fmt, os, path, process, time};
use fmt::Display;
use os::fd::{AsFd, AsRawFd};
@ -498,7 +499,8 @@ impl Display for ContainerInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let volume: String = self.volume.chars().take(20).collect();
let env: String = self.env.chars().take(20).collect();
write!(f, "\x1b[4m{:<10} {:<8} {:<10} {:<20} {:<20} {:<20} {:<10}\x1b[24m", self.id, self.pid, self.image, self.run, volume, env, &self.status)
let run: String = self.run.chars().take(20).collect();
write!(f, "\x1b[4m{:<10} {:<8} {:<10} {:<20} {:<20} {:<20} {:<10}\x1b[24m", self.id, self.pid, self.image, run, volume, env, &self.status)
}
}
@ -572,7 +574,6 @@ fn stop_container(containers_id: &str, is_remove: bool) -> Result<()> {
for container_info in get_all_container_info()?{
stop_container(container_info.id.as_str(), is_remove)?
}
//
return Ok(())
}
for container_id in containers_id.split(" ") {
@ -671,10 +672,10 @@ fn main() -> Result<()>{
Ok(_) => {
if container_info.wait {
println!("🟢 容器 {} 运行完毕", container_info.id);
remove_network(&container_info.id);
} else {
println!("🟢 主进程退出");
}
remove_network(&container_info.id);
}
Err(e) => {
// clone 之后的错误 这里已经无法捕获了

@ -0,0 +1,6 @@
SHLVL=1
PS1=(python_env) \u\h:\W\$
PATH=/python_env/bin:/sbin:/usr/sbin:/bin:/usr/bin
VIRTUAL_ENV_PROMPT=(python_env)
VIRTUAL_ENV=/python_env
PWD=/

@ -4,11 +4,16 @@ import time
while True:
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
request = urllib.request.Request("http://www.baidu.com")
with urllib.request.urlopen(request) as response:
data = response.read()
content = data.decode("utf-8")
print(f"{now} {len(content)}")
time.sleep(1)
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(now)
# try:
# request = urllib.request.Request("http://www.baidu.com")
# with urllib.request.urlopen(request) as response:
# data = response.read()
# content = data.decode("utf-8")
# print(f"{len(content)}")
# except Exception as e:
# print(e)

Loading…
Cancel
Save