mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 06:19:20 +08:00
feat: Optimize openim scripts and standard output logs (#1866)
* feat: add component check func * fix: fix the outpu error * fix: fix the stderr outpu * fix: fix the component check func * fix: fix the error * fix: fix the output error * fix: del the disruptions code * fix the log output format * fix: fix the tools version * fix: fix the cycle detection * fix: fix the error * fix: fix the flag * fix: add mongo ping detection * fix: fix the tools pkg version * fix: del the err * feat: support openim readme docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim readme docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim readme docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fix the minio nil error * fix: del the repeated wrap and add err print * fix: fix this bug scripts * Revert "Check" --------- Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> Co-authored-by: luhaoling <2198702716@qq.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/IBM/sarama"
|
||||
@@ -56,6 +57,7 @@ func initCfg() error {
|
||||
type checkFunc struct {
|
||||
name string
|
||||
function func() error
|
||||
flag bool
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -86,13 +88,17 @@ func main() {
|
||||
|
||||
var err error
|
||||
allSuccess := true
|
||||
for _, check := range checks {
|
||||
err = check.function()
|
||||
if err != nil {
|
||||
component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, err))
|
||||
allSuccess = false
|
||||
} else {
|
||||
component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name))
|
||||
for index, check := range checks {
|
||||
if !check.flag {
|
||||
err = check.function()
|
||||
if err != nil {
|
||||
component.ErrorPrint(fmt.Sprintf("Starting %s failed:%v.", check.name, err))
|
||||
allSuccess = false
|
||||
|
||||
} else {
|
||||
checks[index].flag = true
|
||||
component.SuccessPrint(fmt.Sprintf("%s connected successfully", check.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +126,7 @@ func checkMinio() error {
|
||||
|
||||
// Check if MinIO is enabled
|
||||
if config.Config.Object.Enable != "minio" {
|
||||
return nil
|
||||
return errs.Wrap(errors.New("minio.Enable is empty"))
|
||||
}
|
||||
minio := &component.Minio{
|
||||
ApiURL: config.Config.Object.ApiURL,
|
||||
@@ -130,7 +136,7 @@ func checkMinio() error {
|
||||
SignEndpoint: config.Config.Object.Minio.SignEndpoint,
|
||||
UseSSL: getEnv("MINIO_USE_SSL", "false"),
|
||||
}
|
||||
_, err := component.CheckMinio(minio)
|
||||
err := component.CheckMinio(minio)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -149,7 +155,7 @@ func checkKafka() error {
|
||||
Addr: config.Config.Kafka.Addr,
|
||||
}
|
||||
|
||||
_, kafkaClient, err := component.CheckKafka(kafkaStu)
|
||||
kafkaClient, err := component.CheckKafka(kafkaStu)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+7
-16
@@ -1,17 +1,3 @@
|
||||
// Copyright © 2023 OpenIM. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -22,6 +8,11 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
maxprocs.Set()
|
||||
fmt.Print(runtime.GOMAXPROCS(0))
|
||||
// Set maxprocs with a custom logger that does nothing to ignore logs.
|
||||
maxprocs.Set(maxprocs.Logger(func(string, ...interface{}) {
|
||||
// Intentionally left blank to suppress all log output from automaxprocs.
|
||||
}))
|
||||
|
||||
// Now this will print the GOMAXPROCS value without printing the automaxprocs log message.
|
||||
fmt.Println(runtime.GOMAXPROCS(0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user