diff --git a/src/scripts/starttask.sh b/src/scripts/starttask.sh index a5d03094d..3a24783ee 100755 --- a/src/scripts/starttask.sh +++ b/src/scripts/starttask.sh @@ -29,6 +29,13 @@ systemctl reset-failed "${service_name}" || true readonly id=$(id -u $SUDO_USER) +readonly ubuntu_version=$(lsb_release -rs) +if [[ "${ubuntu_version}" == "16.04" ]]; then + memory_limit="-p MemoryLimit=400M" +else + memory_limit="-p MemoryMax=400M" +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 if [[ "$BOX_ENV" == "cloudron" ]]; then @@ -37,7 +44,7 @@ else binds_to="" fi -systemd-run --unit "${service_name}" --pipe --wait --property=OOMScoreAdjust=-1000 --nice "${nice}" --uid=${id} --gid=${id} \ - ${binds_to} -E HOME=${HOME} -E USER=${SUDO_USER} -E DEBUG=${DEBUG} -E BOX_ENV=${BOX_ENV} -E NODE_ENV=production \ +systemd-run --unit "${service_name}" --pipe --wait --nice "${nice}" --uid=${id} --gid=${id} ${binds_to} ${memory_limit} \ + -E HOME=${HOME} -E USER=${SUDO_USER} -E DEBUG=${DEBUG} -E BOX_ENV=${BOX_ENV} -E NODE_ENV=production \ "${task_worker}" "${task_id}" "${logfile}"