rudimentary cgroup support
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
2d748aebc9
commit
f191b625dc
35
ssm
35
ssm
|
@ -88,6 +88,12 @@ svc() {
|
||||||
declare job_pid
|
declare job_pid
|
||||||
var job_pid
|
var job_pid
|
||||||
|
|
||||||
|
# Cgroups
|
||||||
|
if cgroups; then
|
||||||
|
mkdir -p "$cgroup_home/$service_name"
|
||||||
|
echo "$BASHPID" > "$cgroup_home/$service_name/cgroup.procs"
|
||||||
|
fi
|
||||||
|
|
||||||
svc::cleanup() {
|
svc::cleanup() {
|
||||||
nullexec kill -n "$service_stop_signal" "$job_pid"
|
nullexec kill -n "$service_stop_signal" "$job_pid"
|
||||||
|
|
||||||
|
@ -421,6 +427,7 @@ var service_pid \
|
||||||
service_ready_flag \
|
service_ready_flag \
|
||||||
service_enabled_flag \
|
service_enabled_flag \
|
||||||
service_stopped_flag \
|
service_stopped_flag \
|
||||||
|
cgroup_home \
|
||||||
failed_deps \
|
failed_deps \
|
||||||
svc_pidfile \
|
svc_pidfile \
|
||||||
cfg_path \
|
cfg_path \
|
||||||
|
@ -450,10 +457,11 @@ var service_stop_signal = 15
|
||||||
var service_reload_signal = 1
|
var service_reload_signal = 1
|
||||||
var service_signals = 1 10 12
|
var service_signals = 1 10 12
|
||||||
var service_nologs = 0
|
var service_nologs = 0
|
||||||
|
var usrdir = '/usr/share/ssm'
|
||||||
var systemd = 0
|
var systemd = 0
|
||||||
var systemd_service_path = /etc/systemd/system /run/systemd/system /lib/systemd/system
|
var systemd_service_path = /etc/systemd/system /run/systemd/system /lib/systemd/system
|
||||||
var ssm_config = 0
|
var ssm_config = 0
|
||||||
var usrdir = '/usr/share/ssm'
|
var cgroups = 0
|
||||||
|
|
||||||
## Figure out our full path
|
## Figure out our full path
|
||||||
case "$0" in
|
case "$0" in
|
||||||
|
@ -461,14 +469,6 @@ case "$0" in
|
||||||
(*) _self = "$PWD/$0";;
|
(*) _self = "$PWD/$0";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if (( $UID )); then
|
|
||||||
rundir = "$XDG_RUNTIME_DIR/ssm"
|
|
||||||
logdir = "$HOME/log/ssm"
|
|
||||||
else
|
|
||||||
rundir = '/run/ssm'
|
|
||||||
logdir = '/var/log/ssm'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Warn the user of deprecated stuff.
|
# Warn the user of deprecated stuff.
|
||||||
for p in "/etc/ssm/init.d" "$XDG_CONFIG_HOME/ssm/init.d"; do
|
for p in "/etc/ssm/init.d" "$XDG_CONFIG_HOME/ssm/init.d"; do
|
||||||
if [[ -d "$p" ]]; then
|
if [[ -d "$p" ]]; then
|
||||||
|
@ -477,9 +477,6 @@ for p in "/etc/ssm/init.d" "$XDG_CONFIG_HOME/ssm/init.d"; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Common service path
|
|
||||||
service_path += "$XDG_CONFIG_HOME/ssm/services" '/etc/ssm/services' "$rundir/services" "$usrdir/services"
|
|
||||||
|
|
||||||
# Common config path
|
# Common config path
|
||||||
cfg_path = "$XDG_CONFIG_HOME/ssm" '/etc/ssm'
|
cfg_path = "$XDG_CONFIG_HOME/ssm" '/etc/ssm'
|
||||||
|
|
||||||
|
@ -499,11 +496,25 @@ for (( idx=${#cfg_path[@]}-1; idx>=0; idx-- )); do
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# These depend on who we are
|
||||||
|
if (( $UID )); then
|
||||||
|
rundir := "$XDG_RUNTIME_DIR/ssm"
|
||||||
|
logdir := "$HOME/log/ssm"
|
||||||
|
cgroup_home := "/sys/fs/cgroup/user/$UID/my/ssm"
|
||||||
|
else
|
||||||
|
rundir := '/run/ssm'
|
||||||
|
logdir := '/var/log/ssm'
|
||||||
|
cgroup_home := "/sys/fs/cgroup/ssm"
|
||||||
|
fi
|
||||||
|
|
||||||
# Now create the needed runtime stuff
|
# Now create the needed runtime stuff
|
||||||
for d in "$rundir" "$logdir"; do
|
for d in "$rundir" "$logdir"; do
|
||||||
mkdir -p "$d" || die 3 "Failed to create runtime dir: $d"
|
mkdir -p "$d" || die 3 "Failed to create runtime dir: $d"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Common service path
|
||||||
|
service_path += "$XDG_CONFIG_HOME/ssm/services" '/etc/ssm/services' "$rundir/services" "$usrdir/services"
|
||||||
|
|
||||||
# If $1 is a full path, source it.
|
# If $1 is a full path, source it.
|
||||||
# If not, search for it in the service path.
|
# If not, search for it in the service path.
|
||||||
if [[ $1 == /* ]]; then
|
if [[ $1 == /* ]]; then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user