This commit is contained in:
skiffer-git 2024-04-16 10:47:55 +08:00
parent b96ea0fa4a
commit f5d18d45f9
4 changed files with 12 additions and 9 deletions

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/localcache v0.0.1
github.com/openimsdk/protocol v0.0.62
github.com/openimsdk/tools v0.0.47-alpha.24
github.com/openimsdk/tools v0.0.47-alpha.25
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0
github.com/stretchr/testify v1.9.0

4
go.sum
View File

@ -283,8 +283,8 @@ github.com/openimsdk/gomake v0.0.5 h1:MxKVvhQRPBRhh7rzeu4+bBnqNjEEiX8gn0ojdfplW0
github.com/openimsdk/gomake v0.0.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.62 h1:M9UaBXqllvt1VLSwwQwnVKWewsazC4eISOXuJiCwSjA=
github.com/openimsdk/protocol v0.0.62/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
github.com/openimsdk/tools v0.0.47-alpha.24 h1:QSIgBTi+BkR6dYpR0Yx1BUKqDmwY7QF6jAkAPV0dBPo=
github.com/openimsdk/tools v0.0.47-alpha.24/go.mod h1:e6pAohiwdjhhAfuECXViGlgCrbk8qkNTIhUkFmLit/Q=
github.com/openimsdk/tools v0.0.47-alpha.25 h1:CjxZ891X1iU4GXwl0oisMFXnLBpU1o6pdxs2+b19TXA=
github.com/openimsdk/tools v0.0.47-alpha.25/go.mod h1:e6pAohiwdjhhAfuECXViGlgCrbk8qkNTIhUkFmLit/Q=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=

View File

@ -28,6 +28,7 @@ import (
"github.com/openimsdk/tools/system/program"
"io/ioutil"
"log"
"os"
"path/filepath"
"time"
)
@ -101,7 +102,7 @@ func main() {
flag.StringVar(&configDir, "c", defaultConfigDir, "Configuration dir")
flag.Parse()
fmt.Printf("Index: %d, Config Path: %s\n", index, configDir)
fmt.Printf("%s Index: %d, Config Path: %s\n", filepath.Base(os.Args[0]), index, configDir)
mongoConfig, redisConfig, kafkaConfig, minioConfig, zookeeperConfig, err := initConfig(configDir)
if err != nil {

View File

@ -2,8 +2,9 @@ package main
import (
"fmt"
"github.com/shirou/gopsutil/mem"
"os"
"github.com/shirou/gopsutil/mem"
)
func main() {
@ -13,12 +14,13 @@ func main() {
os.Exit(1)
}
freeMemoryGB := float64(vMem.Free) / float64(1024*1024*1024)
// Use the Available field to get the available memory
availableMemoryGB := float64(vMem.Available) / float64(1024*1024*1024)
if freeMemoryGB < 1.0 {
fmt.Fprintf(os.Stderr, "System free memory is less than 4GB: %.2fGB\n", freeMemoryGB)
if availableMemoryGB < 1.0 {
fmt.Fprintf(os.Stderr, "System available memory is less than 1GB: %.2fGB\n", availableMemoryGB)
os.Exit(1)
} else {
fmt.Printf("System free memory is sufficient: %.2fGB\n", freeMemoryGB)
fmt.Printf("System available memory is sufficient: %.2fGB\n", availableMemoryGB)
}
}