Giter Club home page Giter Club logo

cgroups's Introduction

Erlang cgroups interface

An interface for cgroups manipulation that handles cgroup version details (i.e., differences between v1 and v2) and provides safe usage of the cgroups filesystem mount.

Build

rebar compile

Example

Update or create the cgroup "group1/nested1" with the OS pid 19368, then delete the cgroup path after moving the OS pid back to the root cgroup (executed as root).

# erl -pz ebin
1> application:start(cgroups).
2> OSPid0 = 19368.
3> CGroupPath = "group1/nested1".
4> {ok, CGroups} = cgroups:new().
5> MemoryLimit = case cgroups:version(CGroups) of 1 -> "memory.limit_in_bytes"; 2 -> "memory.high" end.
6> cgroups:update_or_create(CGroupPath,
                            [OSPid0],
                            [{MemoryLimit, "10000000"}],
                            CGroups).
7> cgroups:update("", [OSPid0], [], CGroups).
8> cgroups:delete_recursive(CGroupPath, CGroups).
9> cgroups:destroy(CGroups).

Troubleshooting

cgroups:update/4 and cgroups:update_or_create/4 Errors:

  • Either root execution of beam.smp or setcap cap_sys_admin=+ep /path/to/beam.smp before execution is required for most usage of cgroups
  • A Linux/systemd setup may have the control group setup mode set to hybrid due to it being the recommended default for distributions. However, that mode blocks the use of cgroup controllers (the file /sys/fs/cgroup/unified/cgroup.controllers is empty) because the cgroup controllers can only be mounted in one hierarchy (v1 or v2). If cgroup v1 should be used, the Linux kernel argument systemd.legacy_systemd_cgroup_controller=1 can be used. If cgroup v2 should be used, the Linux kernel argument systemd.unified_cgroup_hierarchy=1 can be used (with systemd >= v226 and kernel >= 4.2) or cgroup_no_v1=all can be used (with kernel >= 4.6).
  • Any non-root use should only use cgroups:update/4 with more limited controllers (memory, pids, possibly cpu and/or io) and all OS pids added elsewhere as root

Author

Michael Truog (mjtruog at protonmail dot com)

License

MIT License

cgroups's People

Contributors

okeuday avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

chaitanyapandit

cgroups's Issues

Test with cgroups v2

If you have tested with cgroups v2, comment here with any success or failures.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.