remove 16.04 related task logic
This commit is contained in:
@@ -31,16 +31,11 @@ systemctl reset-failed "${service_name}" 2>/dev/null || true
|
||||
readonly id=$(id -u $SUDO_USER)
|
||||
readonly ubuntu_version=$(lsb_release -rs)
|
||||
|
||||
if [[ "${ubuntu_version}" == "16.04" ]]; then
|
||||
options="-p TimeoutStopSec=10s -p MemoryLimit=${memory_limit_mb}M --remain-after-exit"
|
||||
else
|
||||
options="-p TimeoutStopSec=10s -p MemoryMax=${memory_limit_mb}M --pipe --wait"
|
||||
options="-p TimeoutStopSec=10s -p MemoryMax=${memory_limit_mb}M --pipe --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.
|
||||
# BindsTo does not work on ubuntu 16, this means that even if box is stopped, the tasks keep running
|
||||
[[ "$BOX_ENV" == "cloudron" ]] && options="${options} -p BindsTo=box.service"
|
||||
fi
|
||||
# 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 237 on ubuntu 18.04 does not apply --nice
|
||||
if [[ "${ubuntu_version}" == "18.04" ]]; then
|
||||
@@ -54,18 +49,5 @@ systemd-run --unit "${service_name}" --nice "${nice}" --uid=${id} --gid=${id} ${
|
||||
"${task_worker}" "${task_id}" "${logfile}"
|
||||
exit_code=$?
|
||||
|
||||
if [[ "${ubuntu_version}" == "16.04" ]]; then
|
||||
sleep 3
|
||||
# we cannot use systemctl is-active because unit is always active until stopped with RemainAfterExit
|
||||
while [[ "$(systemctl show -p SubState ${service_name})" == *"running"* ]]; do
|
||||
echo "Waiting for service ${service_name} to finish"
|
||||
sleep 3
|
||||
done
|
||||
exit_code=$(systemctl show "${service_name}" -p ExecMainStatus | sed 's/ExecMainStatus=//g')
|
||||
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}"
|
||||
|
||||
Reference in New Issue
Block a user