system "docker stop #{container} && docker rm -f #{container}" end
+def set_available_memory
- memory = `awk '($1 == "MemTotal:"){print $2/1048576}' /proc/meminfo`.to_f
We can first create a more generic function by returning a hash.
[7] pry(main)> File.readlines('/proc/meminfo').map {|s| k,v,kb = s.split; {k.chomp(':') => v} } => [{"MemTotal"=>"1003932288"}, {"MemFree"=>"88093888"}, {"MemAvailable"=>"443704320"}, {"Buffers"=>"33081280"}, {"Cached"=>"393810496"}, {"SwapCached"=>"0"}, ...
ok.
- # set container available memory size, minimum size is 1g, maximum size is 30g,
- # take the middle value according to the system memory size.
- [1, 30, Math.sqrt(memory)].sort[1].to_i
That should go to a dedicated function for use by ES container.
ok, i will define 2 function, 1 generic 1 dedicated.
Thanks, Yinsi
+end
2.23.0