systemd 237 ignores --nice value in systemd-run

This commit is contained in:
Girish Ramakrishnan
2020-08-26 17:24:41 -07:00
parent 6901847c49
commit cf9439fb3b
2 changed files with 8 additions and 0 deletions
+7
View File
@@ -42,6 +42,11 @@ else
[[ "$BOX_ENV" == "cloudron" ]] && options="${options} -p BindsTo=box.service"
fi
# systemd 237 on Ubunut 18.04 does not apply --nice
if [[ "${ubuntu_version}" == "18.04" ]]; then
(sleep 1; pid=$(systemctl show "${service_name}" -p MainPID | sed 's/MainPID=//g'); renice -n ${nice} -g ${pid} || true) &
fi
# DEBUG has to be hardcoded because it is not set in the tests. --setenv is required for ubuntu 16 (-E does not work)
systemd-run --unit "${service_name}" --nice "${nice}" --uid=${id} --gid=${id} ${options} \
--setenv HOME=${HOME} --setenv USER=${SUDO_USER} --setenv DEBUG=box:* --setenv BOX_ENV=${BOX_ENV} --setenv NODE_ENV=production \
@@ -59,5 +64,7 @@ if [[ "${ubuntu_version}" == "16.04" ]]; then
systemctl stop "${service_name}" || true # because of remain-after-exit we have to deactivate the service
fi
[[ "${ubuntu_version}" == "18.04" ]] && wait # for the renice subshell we started
echo "Service ${service_name} finished with exit code ${exit_code}"
exit "${exit_code}"