[gentoo-commits] proj/openrc:master commit in: sh/, etc/
commit: 6a5ca2ab368d0a85f51bb559672dba2e3ffcc6be Author: William Hubbs gmail com> AuthorDate: Thu Sep 14 16:40:26 2017 + Commit: William Hubbs gentoo org> CommitDate: Thu Sep 14 21:17:20 2017 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=6a5ca2ab make the procedure for killing child processes of services configurable etc/rc.conf| 29 ++--- sh/rc-cgroup.sh.in | 13 - 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/etc/rc.conf b/etc/rc.conf index d9ad911d..b7296d35 100644 --- a/etc/rc.conf +++ b/etc/rc.conf @@ -277,10 +277,33 @@ rc_tty_number=12 # Set this to YES if you want all of the processes in a service's cgroup # killed when the service is stopped or restarted. -# This should not be set globally because it kills all of the service's -# child processes, and most of the time this is undesirable. Please set -# it in /etc/conf.d/. +# Be aware that setting this to yes means all of a service's +# child processes will be killed. Keep this in mind if you set this to +# yes here instead of for the individual services in +# /etc/conf.d/. # To perform this cleanup manually for a stopped service, you can # execute cgroup_cleanup with /etc/init.d/ cgroup_cleanup or # rc-service cgroup_cleanup. +# The process followed in this cleanup is the following: +# 1. send stopsig (sigterm if it isn't set) to all processes left in the +# cgroup immediately followed by sigcont. +# 2. Send sighup to all processes in the cgroup if rc_send_sighup is +# yes. +# 3. delay for rc_timeout_stopsec seconds. +# 4. send sigkill to all processes in the cgroup unless disabled by +# setting rc_send_sigkill to no. # rc_cgroup_cleanup="NO" + +# If this is yes, we will send sighup to the processes in the cgroup +# immediately after stopsig and sigcont. +#rc_send_sighup="NO" + +# This is the amount of time in seconds that we delay after sending sigcont +# and optionally sighup, before we optionally send sigkill to all +# processes in the # cgroup. +# The default is 90 seconds. +#rc_timeout_stopsec="90" + +# If this is set to no, we do not send sigkill to all processes in the +# cgroup. +#rc_send_sigkill="YES" diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in index 47a007b6..4b713594 100644 --- a/sh/rc-cgroup.sh.in +++ b/sh/rc-cgroup.sh.in @@ -204,10 +204,13 @@ cgroup_cleanup() local pids pids="$(cgroup_get_pids)" if [ -n "${pids}" ]; then - kill -s TERM "${pids}" - sleep 1 - pids="$(cgroup_get_pids)" - [ -n "${pids}" ] && - kill -s KILL "${pids}" + kill -s "${stopsig:-SIGTERM}" ${pids} 2> /dev/null + kill -s SIGCONT ${pids} 2> /dev/null + yesno "${rc_send_sighup:-no}" && + kill -s SIGHUP ${pids} 2> /dev/null + sleep "${rc_timeout_stopsec:-90}" + yesno "${rc_send_sigkill:-yes}" && + kill -s SIGKILL ${pids} 2> /dev/null fi + eend 0 }
[gentoo-commits] proj/openrc:master commit in: sh/, etc/, init.d/
commit: 457f928e793cb1f6ef254935ad07f58b8762c72f Author: William Hubbs gmail com> AuthorDate: Thu Sep 14 15:38:10 2017 + Commit: William Hubbs gentoo org> CommitDate: Thu Sep 14 15:38:10 2017 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=457f928e add support for control groups version 2 This is for #94. etc/rc.conf | 45 +++ init.d/sysfs.in | 100 +++- sh/openrc-run.sh.in | 15 +--- sh/rc-cgroup.sh.in | 51 +++ 4 files changed, 182 insertions(+), 29 deletions(-) diff --git a/etc/rc.conf b/etc/rc.conf index 689e6be2..d9ad911d 100644 --- a/etc/rc.conf +++ b/etc/rc.conf @@ -191,13 +191,43 @@ rc_tty_number=12 ## # LINUX CGROUPS RESOURCE MANAGEMENT -# If you have cgroups turned on in your kernel, this switch controls -# whether or not a group for each controller is mounted under -# /sys/fs/cgroup. -# None of the other options in this section work if this is set to "NO". +# This sets the mode used to mount cgroups. +# "hybrid" mounts cgroups version 2 on /sys/fs/cgroup/unified and +# cgroups version 1 on /sys/fs/cgroup. +# "legacy" mounts cgroups version 1 on /sys/fs/cgroup +# "unified" mounts cgroups version 2 on /sys/fs/cgroup +#rc_cgroup_mode="hybrid" + +# This is a list of controllers which should be enabled for cgroups version 2. +# If hybrid mode is being used, controllers listed here will not be +# available for cgroups version 1. +# This is a global setting. +#rc_cgroup_controllers="" + +# This variable contains the cgroups version 2 settings for your services. +# If this is set in this file, the settings will apply to all services. +# If you want different settings for each service, place the settings in +# /etc/conf.d/foo for service foo. +# The format is to specify the setting and value followed by a newline. +# Multiple settings and values can be specified. +# For example, you would use this to set the maximum memory and maximum +# number of pids for a service. +#rc_cgroup_settings=" +#memory.max 10485760 +#pids.max max +#" +# +# For more information about the adjustments that can be made with +# cgroups version 2, see Documentation/cgroups-v2.txt in the linux kernel +# source tree. +#rc_cgroup_settings="" + +# This switch controls whether or not cgroups version 1 controllers are +# individually mounted under +# /sys/fs/cgroup in hybrid or legacy mode. #rc_controller_cgroups="YES" -# The following settings allow you to set up values for the cgroup +# The following settings allow you to set up values for the cgroups version 1 # controllers for your services. # They can be set in this file;, however, if you do this, the settings # will apply to all of your services. @@ -211,8 +241,9 @@ rc_tty_number=12 # cpu.shares 512 # " # -#For more information about the adjustments that can be made with -#cgroups, see Documentation/cgroups/* in the linux kernel source tree. +# For more information about the adjustments that can be made with +# cgroups version 1, see Documentation/cgroups-v1/* in the linux kernel +# source tree. # Set the blkio controller settings for this service. #rc_cgroup_blkio="" diff --git a/init.d/sysfs.in b/init.d/sysfs.in index a2538114..9f39fb57 100644 --- a/init.d/sysfs.in +++ b/init.d/sysfs.in @@ -107,20 +107,16 @@ mount_misc() fi } -mount_cgroups() +cgroup1_base() { - # set up kernel support for cgroups - if [ -d /sys/fs/cgroup ] && ! mountinfo -q /sys/fs/cgroup; then - if grep -qs cgroup /proc/filesystems; then - ebegin "Mounting cgroup filesystem" - local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}" - mount -n -t tmpfs -o ${opts} cgroup_root /sys/fs/cgroup - eend $? - fi + grep -qw cgroup /proc/filesystems || return 0 + if ! mountinfo -q /sys/fs/cgroup; then + ebegin "Mounting cgroup filesystem" + local opts="${sysfs_opts},mode=755,size=${rc_cgroupsize:-10m}" + mount -n -t tmpfs -o "${opts}" cgroup_root /sys/fs/cgroup + eend $? fi - mountinfo -q /sys/fs/cgroup || return 0 - if ! mountinfo -q /sys/fs/cgroup/openrc; then local agent="@LIBEXECDIR@/sh/cgroup-release-agent.sh" mkdir /sys/fs/cgroup/openrc @@ -129,17 +125,87 @@ mount_cgroups() openrc /sys/fs/cgroup/openrc printf 1 > /sys/fs/cgroup/openrc/notify_on_release fi + return 0 +} - yesno ${rc_controller_cgroups:-YES} && [ -e /proc/cgroups ] || return 0 - while read name hier groups enabled rest; do +cgroup1_controllers() +{ + yesno "${rc_controller_cgroups:-YES}" && [ -e /proc/cgroups ] || return 0 + while read -r name _ _ enabled
[gentoo-commits] proj/openrc:master commit in: sh/, etc/
commit: 8ad460c54ce66aa0900cf872d9ebfacf0c03f9da Author: Doug Freed mtu edu> AuthorDate: Sat Dec 17 18:41:02 2016 + Commit: William Hubbs gentoo org> CommitDate: Sat Dec 17 18:41:02 2016 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=8ad460c5 Fix typos Fixes #99 etc/rc.shutdown.in | 2 +- sh/init.sh.Linux.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.shutdown.in b/etc/rc.shutdown.in index b85a962..de3e09b 100644 --- a/etc/rc.shutdown.in +++ b/etc/rc.shutdown.in @@ -14,7 +14,7 @@ trap : SIGINT SIGQUIT # Try and use stuff in /lib over anywhere else so we can shutdown # local mounts correctly. -LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LDLIBRARY_PATH}" ; export LD_LIBRARY_PATH +LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" ; export LD_LIBRARY_PATH # If $TERM is not set then assume default of @TERM@ # This gives us a nice colour boot :) diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in index 7645775..fcae0d2 100644 --- a/sh/init.sh.Linux.in +++ b/sh/init.sh.Linux.in @@ -32,7 +32,7 @@ unset f if $mountproc; then procfs="proc" - [ "$RC_UNAME" = "GNU/kFreeBSD" ] && proc="linprocfs" + [ "$RC_UNAME" = "GNU/kFreeBSD" ] && procfs="linprocfs" ebegin "Mounting /proc" if ! fstabinfo --mount /proc; then mount -n -t "$procfs" -o noexec,nosuid,nodev proc /proc
[gentoo-commits] proj/openrc:master commit in: sh/, etc/
commit: 80d3928b0d13f09a9c1e82bd27c9fff943d84d43 Author: Austin S. Hemmelgarn gmail com> AuthorDate: Tue Oct 6 20:02:28 2015 + Commit: William Hubbs gentoo org> CommitDate: Tue Oct 6 20:05:35 2015 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=80d3928b cgroups: Add the hugetlb, net_cls and pids controllers Note from WilliamH: I slightly rearranged the code and added the settings in rc.conf. X-Gentoo-Bug: 555488 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=555488 etc/rc.conf.Linux | 9 + sh/rc-cgroup.sh.in | 9 + 2 files changed, 18 insertions(+) diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux index a8ad58b..f04f96e 100644 --- a/etc/rc.conf.Linux +++ b/etc/rc.conf.Linux @@ -62,12 +62,21 @@ rc_tty_number=12 # Set the devices controller settings for this service. #rc_cgroup_devices="" +# Set the hugetlb controller settings for this service. +#rc_cgroup_hugetlb="" + # Set the memory controller settings for this service. #rc_cgroup_memory="" +# Set the net_cls controller settings for this service. +#rc_cgroup_net_cls="" + # Set the net_prio controller settings for this service. #rc_cgroup_net_prio="" +# Set the pids controller settings for this service. +#rc_cgroup_pids="" + # Set this to YES if yu want all of the processes in a service's cgroup # killed when the service is stopped or restarted. # This should not be set globally because it kills all of the service's diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in index 3f34d17..b49c711 100644 --- a/sh/rc-cgroup.sh.in +++ b/sh/rc-cgroup.sh.in @@ -109,12 +109,21 @@ cgroup_set_limits() local devices="${rc_cgroup_devices:-$RC_CGROUP_DEVICES}" [ -n "$devices" ] && cgroup_set_values devices "$devices" + local hugetlb="${rc_cgroup_hugetlb:-$RC_CGROUP_HUGETLB}" + [ -n "$hugetlb" ] && cgroup_set_values hugetlb "$hugetlb" + local memory="${rc_cgroup_memory:-$RC_CGROUP_MEMORY}" [ -n "$memory" ] && cgroup_set_values memory "$memory" + local net_cls="${rc_cgroup_net_cls:-$RC_CGROUP_NET_CLS}" + [ -n "$net_cls" ] && cgroup_set_values net_cls "$net_cls" + local net_prio="${rc_cgroup_net_prio:-$RC_CGROUP_NET_PRIO}" [ -n "$net_prio" ] && cgroup_set_values net_prio "$net_prio" + local pids="${rc_cgroup_pids:-$RC_CGROUP_PIDS}" + [ -n "$pids" ] && cgroup_set_values pids "$pids" + return 0 }
[gentoo-commits] proj/openrc:master commit in: sh/, etc/
commit: abef2fcb2dbcc277bb05f0d9c674d4b47826f17f Author: William Hubbs w.d.hubbs AT gmail DOT com AuthorDate: Fri May 8 16:29:49 2015 + Commit: William Hubbs williamh AT gentoo DOT org CommitDate: Fri May 8 16:39:39 2015 + URL:https://gitweb.gentoo.org/proj/openrc.git/commit/?id=abef2fcb Make the default start, stop and status functions overridable This will make it possible to add support for supervision suites such as runit and s6. etc/rc.conf.in | 6 sh/Makefile | 2 +- sh/openrc-run.sh.in | 75 ++--- sh/start-stop-daemon.sh | 71 ++ 4 files changed, 87 insertions(+), 67 deletions(-) diff --git a/etc/rc.conf.in b/etc/rc.conf.in index 69a5cf2..b16aaff 100644 --- a/etc/rc.conf.in +++ b/etc/rc.conf.in @@ -77,6 +77,12 @@ #rc_crashed_stop=NO #rc_crashed_start=YES +# Set rc_supervisor to use a program to monitor your daemons and restart +# them when they crash. +# Leaving this undefined uses start-stop-daemon, which is OpenRC's +# default. +#rc_supervisor= + # Set rc_nocolor to yes if you do not want colors displayed in OpenRC # output. #rc_nocolor=NO diff --git a/sh/Makefile b/sh/Makefile index ee9d74d..3f8881e 100644 --- a/sh/Makefile +++ b/sh/Makefile @@ -1,7 +1,7 @@ DIR= ${LIBEXECDIR}/sh SRCS= init.sh.in functions.sh.in gendepends.sh.in \ openrc-run.sh.in rc-functions.sh.in tmpfiles.sh.in ${SRCS-${OS}} -INC= rc-mount.sh functions.sh rc-functions.sh +INC= rc-mount.sh functions.sh rc-functions.sh start-stop-daemon.sh BIN= gendepends.sh init.sh openrc-run.sh tmpfiles.sh ${BIN-${OS}} INSTALLAFTER= _installafter diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in index e279f11..4d286b2 100644 --- a/sh/openrc-run.sh.in +++ b/sh/openrc-run.sh.in @@ -125,72 +125,6 @@ _status() fi } -# Template start / stop / status functions -start() -{ - [ -n $command ] || return 0 - local _background= - ebegin Starting ${name:-$RC_SVCNAME} - if yesno ${command_background}; then - if [ -z ${pidfile} ]; then - eend 1 command_background option used but no pidfile specified - return 1 - fi - _background=--background --make-pidfile - fi - if yesno $start_inactive; then - local _inactive=false - service_inactive _inactive=true - mark_service_inactive - fi - eval start-stop-daemon --start \ - --exec $command \ - ${chroot:+--chroot} $chroot \ - ${procname:+--name} $procname \ - ${pidfile:+--pidfile} $pidfile \ - $_background $start_stop_daemon_args \ - -- $command_args - if eend $? Failed to start $RC_SVCNAME; then - service_set_value command ${command} - [ -n ${chroot} ] service_set_value chroot ${chroot} - [ -n ${pidfile} ] service_set_value pidfile ${pidfile} - [ -n ${procname} ] service_set_value procname ${procname} - return 0 - fi - if yesno $start_inactive; then - if ! $_inactive; then - mark_service_stopped - fi - fi - return 1 -} - -stop() -{ - local startcommand=$(service_get_value command) - local startchroot=$(service_get_value chroot) - local startpidfile=$(service_get_value pidfile) - local startprocname=$(service_get_value procname) - command=${startcommand:-$command} - chroot=${startchroot:-$chroot} - pidfile=${startpidfile:-$pidfile} - procname=${startprocname:-$procname} - [ -n $command -o -n $procname -o -n $pidfile ] || return 0 - ebegin Stopping ${name:-$RC_SVCNAME} - start-stop-daemon --stop \ - ${retry:+--retry} $retry \ - ${command:+--exec} $command \ - ${procname:+--name} $procname \ - ${pidfile:+--pidfile} $chroot$pidfile \ - ${stopsig:+--signal} $stopsig - eend $? Failed to stop $RC_SVCNAME -} - -status() -{ - _status -} - yesno $RC_DEBUG set -x _conf_d=${RC_SERVICE%/*}/../conf.d @@ -212,6 +146,15 @@ unset _conf_d # Load any system overrides sourcex -e @SYSCONFDIR@/rc.conf +# load a service supervisor +sourcex @LIBEXECDIR@/sh/start-stop-daemon.sh +if [ -n $rc_supervisor ]; then + if ! sourcex -e @LIBEXECDIR@/sh/${rc_supervisor}.sh; then + ewarn $rc_supervisor is an invalid value for rc_supervisor + ewarn Using the default. + fi +fi + # Set verbose mode if yesno ${rc_verbose:-$RC_VERBOSE}; then EINFO_VERBOSE=yes diff --git a/sh/start-stop-daemon.sh b/sh/start-stop-daemon.sh new file mode 100644 index 000..aae6792 --- /dev/null +++ b/sh/start-stop-daemon.sh @@ -0,0 +1,71 @@ +# Default start /