tasks: remove redundant BindsTo=
This commit is contained in:
@@ -26,18 +26,19 @@ readonly nice="$3"
|
||||
readonly memory_limit_mb="$4" # SI units
|
||||
readonly oom_score_adjust="$5"
|
||||
|
||||
readonly service_name="box-task-${task_id}"
|
||||
systemctl reset-failed "${service_name}" 2>/dev/null || true
|
||||
|
||||
readonly id=$(id -u $SUDO_USER)
|
||||
|
||||
readonly service_name="box-task-${task_id}"
|
||||
|
||||
systemctl reset-failed "${service_name}" 2>/dev/null || true
|
||||
|
||||
options="-p TimeoutStopSec=10s -p MemoryMax=${memory_limit_mb}M -p OOMScoreAdjust=${oom_score_adjust} --wait"
|
||||
|
||||
# Note: BindsTo will kill this task when the box is stopped. but will not kill this task when restarted!
|
||||
# For this reason, we have code to kill the tasks both on shutdown and startup.
|
||||
[[ "$BOX_ENV" == "cloudron" ]] && options="${options} -p BindsTo=box.service"
|
||||
|
||||
# systemd-run is used to create resource limited tasks. the tasks are in separate cgroup and won't get affected by box start/stop
|
||||
# 1. tasks should stop when box code is stopped. in this state, dashboard us unreachable and don't want things in background.
|
||||
# 2. if tasks continue running, box code needs some reconcilation code to track tasks. systemd has no mechanism to handle both stop and restart.
|
||||
# when using BindsTo=box.service , the tasks restart with systemctl restart. This defeats any point of tasks running in background if they start afresh.
|
||||
|
||||
# it seems systemd-run does not return the exit status of the process despite --wait
|
||||
if ! 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 "${task_worker}" "${task_id}" "${logfile}"; then
|
||||
|
||||
Reference in New Issue
Block a user