https://github.com/matsumotory/mruby-virtualing
creating jail environment, limiting resouces, assigning IP address and separating filesystem
https://github.com/matsumotory/mruby-virtualing
Last synced: about 7 hours ago
JSON representation
creating jail environment, limiting resouces, assigning IP address and separating filesystem
- Host: GitHub
- URL: https://github.com/matsumotory/mruby-virtualing
- Owner: matsumotory
- License: other
- Created: 2015-05-14T14:13:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-28T05:57:23.000Z (almost 10 years ago)
- Last Synced: 2024-10-18T18:16:59.182Z (6 months ago)
- Language: Ruby
- Homepage:
- Size: 273 KB
- Stars: 19
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mruby - mruby-virtualing - virtualing is a lightweight virtualization tool for linux processes. (System)
README
# virtualing (mruby-virtualing)
virtualing is a lightweight virtualization tool for linux processes.
creating jail environment, limiting resouces, assigning IP address and separating filesystem
using https://github.com/kazuho/jailing
## install jailing
See https://github.com/kazuho/jailing
## build virtualing
```
rake
```and create `virtualing` binary into current directory.
## example
```ruby
# httpd.rb
Virtualing.new({:resource => {
# cgroup name
:group => "httpd-jail",# cgroup root path
# centos "/cgroup" by default
# ubuntu "/sys/fs/cgroup"
:root => "/cgroup"# CPU [msec] exc: 30000 -> 30%
:cpu_quota => 30000,# IO [Bytes/sec]
:blk_dvnd => "202:0",
:blk_rbps => 10485760,
:blk_wbps => 10485760,# Memory [Bytes]
:mem => 512 * 1024 * 1024,
:oom => true,},
:jail => {
# use chroot instaed of jailing
# :jailing => false,
:path => "/usr/local/bin/jailing",
:root => "/tmp/apache",
:bind => ["/usr/local/apache"],
:ro_bind => ["/usr/local/lib"],
:cmnd => "/usr/local/apache/bin/httpd -X -f /usr/local/apache/conf/httpd.conf"
},:ip => {
:vip => "192.168.0.30",
:dev => "eth0",
},}).run
# callback memory limit event (default :oom)
# }).run_with_mem_eventfd do |ret|
# puts "OOM KILLER!!! > #{ret}"
# end# callback memory limit event for oom
# }).run_with_mem_eventfd(:oom) do |ret|
# puts "OOM KILLER!!! > #{ret}"
# end# callback memory limit event for usage(4MByte)
# }).run_with_mem_eventfd(:usage, 4 * 1024 * 1024) do |ret|
# puts "Usage Up or Down to threadshould !!! > #{ret}"
# end# umount example
# for dir in `mount | grep /var/httpd-jail | awk '{print $3}'`; do sudo umount $dir; done# del vip
# ip addr del $VIP/24 dev eth0
```## run
```
sudo ./virtualing httpd.rb
```### auto memory expansion example
```ruby
Virtualing.new({
#(snip)
:resource => {
#(snip)
:oom => false,
},
#(snip)
}).run_with_mem_eventfd_loop do |ret|
puts "OOM KILLER!!! current memory: #{mem}"
sleep 2
c = Virtualing::MEMORY.new group
mem = mem * 2
c.limit_in_bytes = mem
c.modify
puts "current memory expand to #{mem}"
end
```## License
under the MIT License:
- see LICENSE file