A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(gateway): derive BEAM scheduler count from the environment (#2169)
Hampuse2fccaee7439
diff --git a/fluxer_gateway/config/vm.args.src b/fluxer_gateway/config/vm.args.srcindex c2af0074f..589a3a8a8 100644--- a/fluxer_gateway/config/vm.args.src+++ b/fluxer_gateway/config/vm.args.src@@ -7,8 +7,8 @@-env ERL_PROCESSES 262144+P 262144+Q 65536-+S 6:6-+SDcpu 4:4++S ${FLUXER_ERLANG_SCHEDULERS:-6}:${FLUXER_ERLANG_SCHEDULERS:-6}++SDcpu ${FLUXER_ERLANG_DIRTY_CPU_SCHEDULERS:-4}:${FLUXER_ERLANG_DIRTY_CPU_SCHEDULERS:-4}+SDio 8+sbwt none+sbwtdcpu nonediff --git a/fluxer_gateway/scripts/docker_entrypoint.sh b/fluxer_gateway/scripts/docker_entrypoint.shindex a6985e863..7e6c8e460 100755--- a/fluxer_gateway/scripts/docker_entrypoint.sh+++ b/fluxer_gateway/scripts/docker_entrypoint.sh@@ -4,13 +4,56 @@set -eu+is_positive_int() {+ case "${1:-}" in+ '' | 0* | *[!0-9]*) return 1 ;;+ *) [ "$1" -gt 0 ] ;;+ esac+}++available_cpu_count() {+ cpu_quota=""+ cpu_period=""+ if [ -r /sys/fs/cgroup/cpu.max ]; then+ read -r cpu_quota cpu_period < /sys/fs/cgroup/cpu.max || true+ else+ for cgroup_dir in /sys/fs/cgroup/cpu /sys/fs/cgroup/cpu,cpuacct; do+ if [ -r "$cgroup_dir/cpu.cfs_quota_us" ] && [ -r "$cgroup_dir/cpu.cfs_period_us" ]; then+ read -r cpu_quota < "$cgroup_dir/cpu.cfs_quota_us" || true+ read -r cpu_period < "$cgroup_dir/cpu.cfs_period_us" || true+ break+ fi+ done+ fi+ if is_positive_int "$cpu_quota" && is_positive_int "$cpu_period"; then+ echo "$(((cpu_quota + cpu_period - 1) / cpu_period))"+ return 0+ fi+ cpu_count="$(nproc 2>/dev/null || echo 1)"+ if is_positive_int "$cpu_count"; then+ echo "$cpu_count"+ else+ echo 1+ fi+}+: "${FLUXER_ERLANG_NODE_NAME:[email protected]}": "${FLUXER_ERLANG_COOKIE:=fluxer_gateway_dev_cookie}": "${FLUXER_ERLANG_DIST_PORT:=8081}"+if ! is_positive_int "${FLUXER_ERLANG_SCHEDULERS:-}"; then+ FLUXER_ERLANG_SCHEDULERS="$(available_cpu_count)"+fi++if ! is_positive_int "${FLUXER_ERLANG_DIRTY_CPU_SCHEDULERS:-}"; then+ FLUXER_ERLANG_DIRTY_CPU_SCHEDULERS="$(((FLUXER_ERLANG_SCHEDULERS * 2 + 2) / 3))"+fi+export FLUXER_ERLANG_NODE_NAMEexport FLUXER_ERLANG_COOKIEexport FLUXER_ERLANG_DIST_PORT+export FLUXER_ERLANG_SCHEDULERS+export FLUXER_ERLANG_DIRTY_CPU_SCHEDULERSexport RELX_REPLACE_OS_VARS="${RELX_REPLACE_OS_VARS:-true}"exec /opt/fluxer_gateway/bin/fluxer_gateway foreground >/dev/null 2>&1