File: README_systemd

package info (click to toggle)
libcgroup 0.41-8%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,540 kB
  • sloc: ansic: 18,963; sh: 12,765; yacc: 455; makefile: 165; cpp: 123; lex: 37
file content (69 lines) | stat: -rw-r--r-- 2,852 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Integration with systemd
========================

systemd is a system and service manager for Linux, compatible with SysV
and LSB init scripts. systemd heavily uses control groups to manage and control
services.

Most of the libcgroup tools and APIs can be safely used on systems with systemd
without any problems. This document attempts to describe the configuration of
systemd and libcgroup so they can safely co-exist and mutually benefit each
other.

References
==========
[1] http://www.freedesktop.org/wiki/Software/systemd
Systemd home page.

[2] http://www.freedesktop.org/wiki/Software/systemd/PaxControlGroups
This is the most useful document describing systemd expectations on applications
(incl. libcgroup tools).


Compilation
===========
As stated in [2], libcgroup should not interact with the 'name=systemd'
hierarchy. Compile libcgroup with the --enable-opaque-hierarchy configure option
to do so:

./configure --enable-opaque-hierarchy=name=systemd

Consequently, the 'name=systemd' hierarchy will not be visible to libcgroup and
all of its tools. For example, the lscgroup command will not list systemd
cgroups and the cgclear command will not remove them.

Start-up and services
====================

Systemd automatically mounts all available controllers on system boot ('cpu' and
'cpuacct' together in one hierarchy by default) and can automatically put
service processes into control groups with configured parameters — by default,
each service is automatically put into the 'cpu,cpuacct:/system/$service_name'
control group. The System Administrator has full control of parameters in each
control group and of which controllers are used. Consult systemd
documentation, mainly systemd.conf(5) and systemd.exec(5) man pages, for
details.

In the vast majority of use cases, this behavior is sufficient and libcgroup
does not need to be used.

For specific use cases, e.g. when a different tree of control groups is needed,
libcgroup provides cgconfig service. This service can create arbitrary control
group hierarchies. In this case, follow these steps:

1. Set 'DefaultControllers=' in /etc/systemd/system.conf so that systemd does
not create control groups for services automatically.

2. Prepare /etc/cgconfig.conf and enable the cgconfig service. The service will
parse the /etc/cgconfig.conf file during machine boot and create all control
groups which are defined in it. The service automatically sets '+t' ("sticky")
bit on the tasks files as recommended in [2].

3. For each service that should start in a specific control group, add the
following lines into its unit file:
	After=cgconfig.service
	ControlGroup=<name of the control group(s)>

This ensures the service is started only after cgconfig creates the necessary
hierarchy for it. It also tells systemd which control group it should use to
start the service.