[#72] Support soft memory limit setting

Signed-off-by: Roman Loginov <r.loginov@yadro.com>
This commit is contained in:
Roman Loginov 2023-08-31 19:19:57 +03:00 committed by Alexey Vanin
parent 834d5b93e5
commit 40568590c7
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)
}