Merge pull request #1368 from Maxtonian/mmap

Mmap limit comparison warning message for Linux
This commit is contained in:
Maxton Huff 2021-01-27 10:33:43 -06:00 • committed by GitHub
commit 4b33a7fe16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

@ -1 +1 @@
Subproject commit 36f453c1ea3bf86c546a8ad4a88f2a926724d683
Subproject commit 28c2313ecfcd7e083d42d4e409483e968b4c421b

View file

@ -24,6 +24,7 @@ import (
"context"
"crypto/tls"
"io"
"io/ioutil"
"log"
"math/rand"
"net"
@ -31,6 +32,7 @@ import (
"os/signal"
"runtime"
"strconv"
"strings"
"sync"
"syscall"
"time"
@ -152,6 +154,20 @@ func (m *Command) Start() (err error) {
return errors.Wrap(err, "setting up server")
}
if runtime.GOOS == "linux" {
result, err := ioutil.ReadFile("/proc/sys/vm/max_map_count")
if err != nil {
m.logger.Printf("Tried unsuccessfully to check system mmap limit: %v", err)
} else {
sysMmapLimit, err := strconv.ParseUint(strings.TrimSuffix(string(result), "\n"), 10, 64)
if err != nil {
m.logger.Printf("Tried unsuccessfully to check system mmap limit: %v", err)
} else if m.Config.MaxMapCount > sysMmapLimit {
m.logger.Printf("WARNING: Config max map limit (%v) is greater than current system limits (%v)", m.Config.MaxMapCount, sysMmapLimit)
}
}
}
// Set up networking (i.e. gossip)
err = m.setupNetworking()
if err != nil {