mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
This patch adds support for modifying settings for the default cgroups;
init, user, and system, as well as adding up to a total of eight groups
for the system.
Services can now be assigned to a cgroup, with optional extra settings
for that particular process group. The syntax is slightly contrivied
but follows the overall Finit syntax of prop:value,prop':value', e.g.
cgroup maint cpu.weight:123,mem.max:10000
Starting with the introduction of rlimits, a group of services sharing
the same .conf file can share the same (locally "global") rlimits, and
now also the same cgroup, e.g.
cgroup.maint
service foo
service bar cgroup:mem.max:1000
This puts foo and bar in the same top-level cgroup 'maint', with an
extra memory restriction on bar for max 1000 bytes memory.
NOTE: 'mem.' is a Finit extension, a shorthand for cgroups2 'memory.'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
78 lines
2.8 KiB
Plaintext
78 lines
2.8 KiB
Plaintext
# Sample finit.conf to demonstrate the syntax
|
|
#
|
|
host testbed
|
|
|
|
# Linux kernel modules to load
|
|
module button
|
|
module evdev
|
|
module loop
|
|
module psmouse
|
|
|
|
# Top-level cgroups and their default settings. All groups mandatory
|
|
# but more can be added, max 8 groups in total currently. The cgroup
|
|
# 'root' is also available, reserved for RT processes. Settings are
|
|
# as-is, only one shorthand 'mem.' exists, other than that it's the
|
|
# cgroup v2 controller default names.
|
|
cgroup init cpu.weight:100
|
|
cgroup user cpu.weight:100
|
|
cgroup system cpu.weight:9700 cpu.max:50000
|
|
|
|
# Example extra cgroup
|
|
cgroup maint cpu.weight:100
|
|
|
|
# Runlevel to start after bootstrap, runlevel 'S'
|
|
runlevel 2
|
|
|
|
# Network bringup script
|
|
network service networking start
|
|
|
|
# Max file size for each log file: 100 kiB, rotate max 4 copies:
|
|
# log => log.1 => log.2.gz => log.3.gz => log.4.gz
|
|
log size:100k count:4
|
|
|
|
# Virtual consoles to start getty on
|
|
tty /dev/tty1
|
|
tty /dev/tty2
|
|
tty /dev/tty3
|
|
|
|
# Alternative method instead of runparts
|
|
#task [S] /etc/init.d/keyboard-setup start -- Setting up preliminary keymap
|
|
#task [S] /etc/init.d/acpid start -- Starting ACPI Daemon
|
|
#task [S] /etc/init.d/kbd start -- Preparing console
|
|
#run [2] /etc/init.d/networking start -- Start networking
|
|
|
|
# Services to be monitored and respawned as needed
|
|
|
|
# klgod and syslogd are placed in the maint cgroup
|
|
cgroup.maint
|
|
service [2345] <pid/syslogd> klogd -n -- Kernel logging server
|
|
service [2345] syslogd -n -- Syslog server
|
|
|
|
# gdm in the system cgroup (default when read from it's own .conf file)
|
|
cgroup.system
|
|
service [3] cgroup:cpu.weight:250,mem.max:10M gdm -- GNOME Display Manager
|
|
|
|
# Start SSH daemon with opts from /etc/default/ssh (if available), move
|
|
# to user cgroup with cpu.weight:250. Default for services is system
|
|
# group. Default weight in user group is 100 (above). Max length of
|
|
# cgroup argument is (currently) 63 chars.
|
|
#
|
|
# Notice alternative syntax where current cgroup is only set for this
|
|
# particular service.
|
|
service [2345] cgroup.user:cpu.weight:250,mem.max:10M env:-/etc/default/ssh /usr/sbin/sshd -D $SSHD_OPTS -- OpenSSH daemon
|
|
|
|
# The BusyBox ntpd does not use syslog when running in the foreground
|
|
# So we use this trick to redirect stdout/stderr to a log file. The
|
|
# log file is rotated with the above settings. The condition declares
|
|
# a dependency on a system default route (gateway) to be set. A single
|
|
# <!> at the beginning means ntpd does not respect SIGHUP for restart.
|
|
service [2345] <!net/route/default> log:/var/log/ntpd.log ntpd -n -l -I eth0 -- NTP daemon
|
|
|
|
# Run start scripts from this directory
|
|
# runparts /etc/start.d
|
|
|
|
# For multiple instances of the same service, add :ID somewhere between
|
|
# the service/run/task keyword and the command.
|
|
service :80 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
|
|
service :8080 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
|