Skip to content

Commit

Permalink
shadowsocks: set GOMEMLIMIT env
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Sep 25, 2022
1 parent bafa6b6 commit b18ea97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions trunk/user/shadowsocks/scripts/shadowsocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,22 @@ find_bin() {
echo $ret
}

go_mem_limit() {
mem_limit=$(nvram get ss_cgoups_mem_s)
if [ -n "$mem_limit" ]; then
echo "${mem_limit}iB"
else
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
echo "$(($mem_total / 2))KiB"
fi
}

run_bin() {
(if [ "$(nvram get ss_cgroups)" = "1" ]; then
echo 0 > /sys/fs/cgroup/cpu/$NAME/tasks
echo 0 > /sys/fs/cgroup/memory/$NAME/tasks
fi
export GOMEMLIMIT=$(go_mem_limit)
"$@" > /dev/null 2>&1
) &
}
Expand Down
11 changes: 11 additions & 0 deletions trunk/user/shadowsocks/scripts/ssr-monitor
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,22 @@ log() {
echo "$(date "+%Y-%m-%d %H:%M:%S") $@" >> "/tmp/ssrplus.log"
}

go_mem_limit() {
mem_limit=$(nvram get ss_cgoups_mem_s)
if [ -n "$mem_limit" ]; then
echo "${mem_limit}iB"
else
mem_total=$(grep MemTotal /proc/meminfo | awk '{print $2}')
echo "$(($mem_total / 2))KiB"
fi
}

run_bin() {
(if [ "$(nvram get ss_cgroups)" = "1" ]; then
echo 0 > /sys/fs/cgroup/cpu/$NAME/tasks
echo 0 > /sys/fs/cgroup/memory/$NAME/tasks
fi
export GOMEMLIMIT=$(go_mem_limit)
"$@" > /dev/null 2>&1
) &
}
Expand Down

0 comments on commit b18ea97

Please sign in to comment.