[#72] Support soft memory limit setting
All checks were successful
/ Vulncheck (pull_request) Successful in 1m19s
/ Lint (pull_request) Successful in 2m47s
/ Tests (1.20) (pull_request) Successful in 1m47s
/ Tests (1.21) (pull_request) Successful in 1m37s
/ DCO (pull_request) Successful in 3m40s
/ Builds (1.20) (pull_request) Successful in 5m53s
/ Builds (1.21) (pull_request) Successful in 1m39s

Signed-off-by: Roman Loginov <r.loginov@yadro.com>
This commit is contained in:
Roman Loginov 2023-08-31 19:19:57 +03:00
parent 7d47e88e36
commit 6b18dd5d2a
6 changed files with 121 additions and 65 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"fmt"
"math"
"os"
"path"
"runtime"
@ -36,6 +37,8 @@ const (
defaultPoolErrorThreshold uint32 = 100
defaultSoftMemoryLimit = math.MaxInt64
cfgServer = "server"
cfgTLSEnabled = "tls.enabled"
cfgTLSCertFile = "tls.cert_file"
@ -90,6 +93,9 @@ const (
// Zip compression.
cfgZipCompression = "zip.compression"
// Runtime.
cfgSoftMemoryLimit = "runtime.soft_memory_limit"
// Command line args.
cmdHelp = "help"
cmdVersion = "version"
@ -516,3 +522,12 @@ func fetchPeers(l *zap.Logger, v *viper.Viper) []pool.NodeParam {
return nodes
}
func fetchSoftMemoryLimit(cfg *viper.Viper) int64 {
softMemoryLimit := cfg.GetSizeInBytes(cfgSoftMemoryLimit)
if softMemoryLimit <= 0 {
softMemoryLimit = defaultSoftMemoryLimit
}
return int64(softMemoryLimit)
}