File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
fs/etc/s6-overlay/s6-rc.d Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
1
#!/command/with-contenv sh
2
2
3
- MEMLIMIT=$(free -m | awk '/Mem:/ {print int($2 * 2 / 3)}')
3
+ MEMLIMIT=$(free -m | awk '/Mem:/ {printf "%d\n", int($2 * 2 / 3)}')
4
4
5
5
CG_LIMIT_FILE="/sys/fs/cgroup/memory/memory.limit_in_bytes"
6
6
if [ -f "/sys/fs/cgroup/cgroup.controllers" ]; then
7
7
CG_LIMIT_FILE="/sys/fs/cgroup/memory.max"
8
8
fi
9
9
10
10
if [ -r "${CG_LIMIT_FILE}" ]; then
11
- MEMLIMIT_CG=$(awk '{print int($1 / 1024 / 1024 * 2 / 3)}' "${CG_LIMIT_FILE}")
11
+ if grep -q '^max$' "${CG_LIMIT_FILE}"; then
12
+ MEMLIMIT_CG="${MEMLIMIT}"
13
+ else
14
+ MEMLIMIT_CG=$(awk '{printf "%d\n", int($1 / 1024 / 1024 * 2 / 3)}' "${CG_LIMIT_FILE}")
15
+ fi
12
16
13
17
if [ "${MEMLIMIT_CG}" -gt 0 ]; then
14
18
if [ "${MEMLIMIT_CG}" -lt "${MEMLIMIT}" ]; then
Original file line number Diff line number Diff line change 1
1
#!/command/with-contenv sh
2
2
3
- MEMLIMIT=$(free -m | awk '/Mem:/ {print int($2 / 3)}')
3
+ MEMLIMIT=$(free -m | awk '/Mem:/ {printf "%d\n", int($2 / 3)}')
4
4
5
5
CG_LIMIT_FILE="/sys/fs/cgroup/memory/memory.limit_in_bytes"
6
6
if [ -f "/sys/fs/cgroup/cgroup.controllers" ]; then
7
7
CG_LIMIT_FILE="/sys/fs/cgroup/memory.max"
8
8
fi
9
9
10
10
if [ -r "${CG_LIMIT_FILE}" ]; then
11
- MEMLIMIT_CG=$(awk '{print int($1 / 1024 / 1024 / 3)}' "${CG_LIMIT_FILE}")
11
+ if grep -q '^max$' "${CG_LIMIT_FILE}"; then
12
+ MEMLIMIT_CG="${MEMLIMIT}"
13
+ else
14
+ MEMLIMIT_CG=$(awk '{printf "%d\n", int($1 / 1024 / 1024 / 3)}' "${CG_LIMIT_FILE}")
15
+ fi
12
16
13
17
if [ "${MEMLIMIT_CG}" -gt 0 ]; then
14
18
if [ "${MEMLIMIT_CG}" -lt "${MEMLIMIT}" ]; then
You can’t perform that action at this time.
0 commit comments