mirror of
https://github.com/mii443/izoli.git
synced 2025-08-22 16:05:40 +00:00
add pids.max
This commit is contained in:
@ -29,10 +29,11 @@ fn main() {
|
|||||||
max: CGroupLimitValue::Max,
|
max: CGroupLimitValue::Max,
|
||||||
period: 100000,
|
period: 100000,
|
||||||
}),
|
}),
|
||||||
memory_max: Some(CGroupLimitValue::Value(1024 * 1024 * 2)),
|
memory_max: Some(CGroupLimitValue::Value(1024 * 1024 * 1024)),
|
||||||
|
pids_max: Some(CGroupLimitValue::Value(3)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
new_net: true,
|
new_net: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -58,6 +58,11 @@ impl CGroup {
|
|||||||
self.set_memory_max(memory_max)?;
|
self.set_memory_max(memory_max)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(pids_max) = &option.pids_max {
|
||||||
|
info!("setting pids.max");
|
||||||
|
self.set_pids_max(pids_max)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +233,22 @@ impl CGroup {
|
|||||||
self.write("memory.max", &to_write)
|
self.write("memory.max", &to_write)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pids read
|
||||||
|
|
||||||
|
pub fn get_pids_max(&self) -> Result<CGroupLimitValue<u32>, std::io::Error> {
|
||||||
|
let max = self.read("pids.max")?;
|
||||||
|
|
||||||
|
Ok(CGroupLimitValue::from_str(&max).unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
// pids write
|
||||||
|
|
||||||
|
pub fn set_pids_max(&self, pids_limit: &CGroupLimitValue<u32>) -> Result<(), std::io::Error> {
|
||||||
|
let to_write = pids_limit.to_string();
|
||||||
|
|
||||||
|
self.write("pids.max", &to_write)
|
||||||
|
}
|
||||||
|
|
||||||
fn write_value<T>(&self, name: &str, value: T) -> Result<(), std::io::Error>
|
fn write_value<T>(&self, name: &str, value: T) -> Result<(), std::io::Error>
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
|
@ -4,4 +4,5 @@ use super::{cpu_limit::CpuLimit, limit_value::CGroupLimitValue};
|
|||||||
pub struct CGroupOption {
|
pub struct CGroupOption {
|
||||||
pub cpu_max: Option<CpuLimit>,
|
pub cpu_max: Option<CpuLimit>,
|
||||||
pub memory_max: Option<CGroupLimitValue<u32>>,
|
pub memory_max: Option<CGroupLimitValue<u32>>,
|
||||||
|
pub pids_max: Option<CGroupLimitValue<u32>>,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user