Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add very basic Linux control groups support #215

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adembo
Copy link

@adembo adembo commented Feb 8, 2013

Control groups (cgroups) are a Linux kernel feature that can be used for
resource management and isolation between processes. In my case, I have an
out-of-band application that manages the cgroups themselves, but as I use
supervisor to manage process lifecycle, it's well positioned to attach
processes to cgroups, and to reattach them if they're autorestarted.

Here we do that, with two main changes:

  1. After forking a process, supervisor will attach it to every desired
    cgroup by writing its pid to each 'tasks' pseudofile. Note that cgroup
    membership is per-thread (not per-process), but at this stage in the
    process' life, it should be single threaded.
  2. When queried for process information, supervisor will also mention
    if the process has cgroups or not. Ideally we'd take into account whether
    attaching actually succeeded, but effecting that change in the parent is
    tough from the forked child.

Control groups (cgroups) are a Linux kernel feature that can be used for
resource management and isolation between processes. In my case, I have an
out-of-band application that manages the cgroups themselves, but as I use
supervisor to manage process lifecycle, it's well positioned to attach
processes to cgroups, and to reattach them if they're autorestarted.

Here we do that, with two main changes:
1. After forking a process, supervisor will attach it to every desired
   cgroup by writing its pid to each 'tasks' pseudofile. Note that cgroup
   membership is per-thread (not per-process), but at this stage in the
   process' life, it should be single threaded.
2. When queried for process information, supervisor will also mention
   if the process has cgroups or not. Ideally we'd take into account whether
   attaching actually succeeded, but effecting that change in the parent is
   tough from the forked child.
@mnaberez mnaberez added the linux label Aug 19, 2016
@gtt116
Copy link

gtt116 commented Jan 10, 2017

I love the idea to make supervisor support controlling process's cgroup. As we know systemd support cgroup now, if supervisor can support this feature will be amazing.

@luto
Copy link
Contributor

luto commented Apr 11, 2017

@mnaberez is there any interest in this feature? I'd love to code something similar to this up for a PR.

@pavel-orekhov
Copy link

@mnaberez is there any interest in this feature? I'd love to code something similar to this up for a PR.
Yes. I have interest is this feature.

@JoveYu
Copy link

JoveYu commented Sep 25, 2018

may be pid should append to task not overwrite

@f18m
Copy link

f18m commented Apr 25, 2020

Hi all,
I'd love to have such feature built into supervisord as well... any comment from SupervisorD maintainers on this PR ?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

7 participants