Set OOMScoreAdjust to stop box code from being killed
OOMScoreAdjust can be set between -1000 and +1000. This value is inherited and systemd has no easy way to control this for children (box code also runs as non-root, so it cannot easily set it for the children using /proc/<pid>/oom_score_adj. When set to -1000 and the process reaches the MemoryMax, it seems the kernel does not kill any process in the cgroup and it spins up in high memory. In fact, 'systemctl status <service>' stops displaying child process (but ps does), not sure what is happenning. Keeping it -999 means that if a child process consumed a lot of memory, the kernel will kill something in the group. If the main box itself is killed, systemd will kill it at all because of KillMode=control-group. Keeping it -999 also saves box service group being killed relative to other docker processes (apps and addons). Fixes #605
This commit is contained in:
@@ -17,9 +17,12 @@ ExecStart=/bin/sh -c 'echo "Logging to /home/yellowtent/platformdata/logs/box.lo
|
||||
Environment="HOME=/home/yellowtent" "USER=yellowtent" "DEBUG=box*,connect-lastmile" "BOX_ENV=cloudron" "NODE_ENV=production"
|
||||
; kill apptask processes as well
|
||||
KillMode=control-group
|
||||
; Do not kill this process on OOM. Children inherit this score. Do not set it to -1000 so that MemoryMax can keep working
|
||||
OOMScoreAdjust=-999
|
||||
User=yellowtent
|
||||
Group=yellowtent
|
||||
MemoryLimit=400M
|
||||
; OOM killer is invoked in this unit beyond this
|
||||
MemoryMax=400M
|
||||
TimeoutStopSec=5s
|
||||
StartLimitInterval=1
|
||||
StartLimitBurst=60
|
||||
|
||||
Reference in New Issue
Block a user