{"id":13750659,"url":"https://github.com/matsumotory/mruby-virtualing","last_synced_at":"2025-04-30T08:24:44.987Z","repository":{"id":32043454,"uuid":"35614967","full_name":"matsumotory/mruby-virtualing","owner":"matsumotory","description":"creating jail environment, limiting resouces, assigning IP address and separating filesystem","archived":false,"fork":false,"pushed_at":"2015-05-28T05:57:23.000Z","size":280,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-18T18:16:59.182Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matsumotory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-14T14:13:19.000Z","updated_at":"2019-08-18T16:44:38.000Z","dependencies_parsed_at":"2022-09-02T20:21:56.975Z","dependency_job_id":null,"html_url":"https://github.com/matsumotory/mruby-virtualing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-virtualing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-virtualing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-virtualing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matsumotory%2Fmruby-virtualing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matsumotory","download_url":"https://codeload.github.com/matsumotory/mruby-virtualing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251667542,"owners_count":21624518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T08:00:43.704Z","updated_at":"2025-04-30T08:24:44.965Z","avatar_url":"https://github.com/matsumotory.png","language":"Ruby","readme":"# virtualing (mruby-virtualing)\n\nvirtualing is a lightweight virtualization tool for linux processes.\n\ncreating jail environment, limiting resouces, assigning IP address and separating filesystem\n\nusing https://github.com/kazuho/jailing\n\n## install jailing\n\nSee https://github.com/kazuho/jailing\n\n## build virtualing\n```\nrake\n```\n\nand create `virtualing` binary into current directory.\n\n## example\n```ruby\n# httpd.rb\nVirtualing.new({\n\n  :resource =\u003e {\n\n    # cgroup name\n    :group =\u003e \"httpd-jail\",\n\n    # cgroup root path\n    # centos \"/cgroup\" by default\n    # ubuntu \"/sys/fs/cgroup\"\n    :root =\u003e \"/cgroup\"\n\n    # CPU [msec] exc: 30000 -\u003e 30%\n    :cpu_quota =\u003e 30000,\n\n    # IO [Bytes/sec]\n    :blk_dvnd =\u003e \"202:0\",\n    :blk_rbps =\u003e 10485760,\n    :blk_wbps =\u003e 10485760,\n\n    # Memory [Bytes]\n    :mem =\u003e 512 * 1024 * 1024,\n    :oom =\u003e true,\n\n  },\n\n  :jail =\u003e {\n    # use chroot instaed of jailing\n    # :jailing =\u003e false,\n    :path =\u003e \"/usr/local/bin/jailing\",\n    :root =\u003e \"/tmp/apache\",\n    :bind =\u003e [\"/usr/local/apache\"],\n    :ro_bind =\u003e [\"/usr/local/lib\"],\n    :cmnd =\u003e \"/usr/local/apache/bin/httpd -X -f /usr/local/apache/conf/httpd.conf\"\n  },\n\n  :ip =\u003e {\n    :vip   =\u003e \"192.168.0.30\",\n    :dev  =\u003e \"eth0\",\n  },\n\n}).run\n# callback memory limit event (default :oom)\n# }).run_with_mem_eventfd do |ret|\n#   puts \"OOM KILLER!!! \u003e #{ret}\"\n# end\n\n# callback memory limit event for oom\n# }).run_with_mem_eventfd(:oom) do |ret|\n#   puts \"OOM KILLER!!! \u003e #{ret}\"\n# end\n\n# callback memory limit event for usage(4MByte)\n# }).run_with_mem_eventfd(:usage, 4 * 1024 * 1024) do |ret|\n#   puts \"Usage Up or Down to threadshould !!! \u003e #{ret}\"\n# end\n\n# umount example\n# for dir in `mount | grep /var/httpd-jail | awk '{print $3}'`; do sudo umount $dir; done\n\n# del vip\n# ip addr del $VIP/24 dev eth0\n```\n\n## run\n```\nsudo ./virtualing httpd.rb\n```\n\n### auto memory expansion example\n```ruby\nVirtualing.new({\n#(snip)\n  :resource =\u003e {\n    #(snip)\n    :oom =\u003e false,\n  },\n#(snip)\n}).run_with_mem_eventfd_loop do |ret|\n  puts \"OOM KILLER!!! current memory: #{mem}\"\n  sleep 2\n  c = Virtualing::MEMORY.new group\n  mem = mem * 2\n  c.limit_in_bytes = mem\n  c.modify\n  puts \"current memory expand to #{mem}\"\nend\n```\n\n## License\nunder the MIT License:\n- see LICENSE file\n\n","funding_links":[],"categories":["System"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsumotory%2Fmruby-virtualing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatsumotory%2Fmruby-virtualing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatsumotory%2Fmruby-virtualing/lists"}