mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 11:52:10 +08:00
Merge remote-tracking branch 'origin/3.6.1-code-conventions' into 3.6.1-code-conventions
This commit is contained in:
commit
809e3786c1
@ -593,11 +593,12 @@ linters-settings:
|
||||
- name: exported
|
||||
severity: warning
|
||||
- name: var-naming
|
||||
arguments: [ ["ID", "HTTP", "URL", "URI", "URL", "URI", "API", "APIKey", "Token", "TokenID", "TokenSecret", "TokenKey", "TokenSecret", "JWT", "JWTToken", "JWTTokenID", "JWTTokenSecret", "JWTTokenKey", "JWTTokenSecret", "OAuth", "OAuthToken", "OAuth" ] ]
|
||||
arguments: [ [ "OpenIM"] ]
|
||||
# arguments: [ ["ID", "HTTP", "URL", "URI", "API", "APIKey", "Token", "TokenID", "TokenSecret", "TokenKey", "TokenSecret", "JWT", "JWTToken", "JWTTokenID", "JWTTokenSecret", "JWTTokenKey", "JWTTokenSecret", "OAuth", "OAuthToken", "RPC" ] ]
|
||||
- name: atomic
|
||||
- name: line-length-limit
|
||||
severity: error
|
||||
arguments: [80]
|
||||
arguments: [200]
|
||||
- name: unhandled-error
|
||||
arguments : ["fmt.Printf", "myFunction"]
|
||||
|
||||
|
||||
2
pkg/common/db/cache/conversation.go
vendored
2
pkg/common/db/cache/conversation.go
vendored
@ -38,7 +38,7 @@ const (
|
||||
// recvMsgOptKey = "RECV_MSG_OPT:"
|
||||
// superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
|
||||
// superGroupRecvMsgNotNotifyUserIDsHashKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS_HASH:"
|
||||
//conversationNotReceiveMessageUserIDsKey = "CONVERSATION_NOT_RECEIVE_MESSAGE_USER_IDS:".
|
||||
// conversationNotReceiveMessageUserIDsKey = "CONVERSATION_NOT_RECEIVE_MESSAGE_USER_IDS:".
|
||||
|
||||
conversationExpireTime = time.Second * 60 * 60 * 12
|
||||
)
|
||||
|
||||
@ -575,7 +575,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
|
||||
//
|
||||
//}
|
||||
// var seqs []int64
|
||||
//for i := end; i > end-num; i-- {
|
||||
// for i := end; i > end-num; i-- {
|
||||
// if i >= begin {
|
||||
// seqs = append([]int64{i}, seqs...)
|
||||
// } else {
|
||||
|
||||
@ -82,6 +82,7 @@ func (cli *K8sDR) GetUserIdHashGatewayHost(ctx context.Context, userId string) (
|
||||
}
|
||||
return host, err
|
||||
}
|
||||
|
||||
func getSelfHost(ctx context.Context, gatewayName string) string {
|
||||
port := 88
|
||||
instance := "openimserver"
|
||||
|
||||
@ -16,18 +16,9 @@
|
||||
#FIXME This script is the startup script for multiple servers.
|
||||
#FIXME The full names of the shell scripts that need to be started are placed in the `need_to_start_server_shell` array.
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
source "${OPENIM_ROOT}/scripts/install/common.sh"
|
||||
|
||||
|
||||
|
||||
# Function to execute the scripts.
|
||||
function execute_start_scripts() {
|
||||
for script_path in "${OPENIM_SERVER_SCRIPT_START_LIST[@]}"; do
|
||||
@ -58,37 +49,29 @@ function execute_start_scripts() {
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if openim::util::is_running_in_container; then
|
||||
exec >> ${DOCKER_LOG_FILE} 2>&1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
openim::golang::check_openim_binaries
|
||||
if [[ $? -ne 0 ]]; then
|
||||
openim::log::error "OpenIM binaries are not found. Please run 'make build' to build binaries."
|
||||
"${OPENIM_ROOT}"/scripts/build-all-service.sh
|
||||
fi
|
||||
|
||||
|
||||
"${OPENIM_ROOT}"/scripts/init-config.sh --skip
|
||||
|
||||
#openim::log::print_blue "Execute the following script in sequence: ${OPENIM_SERVER_SCRIPTARIES[@]}"
|
||||
|
||||
|
||||
# TODO Prelaunch tools, simple for now, can abstract functions later
|
||||
TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh
|
||||
|
||||
openim::log::status "Start the pre-start tools:"
|
||||
|
||||
|
||||
if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then
|
||||
openim::log::error "Start the pre-start tools, aborting!"
|
||||
exit 1
|
||||
fi
|
||||
# if ! ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start; then
|
||||
# openim::log::error "Start the pre-start tools, aborting!"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
|
||||
openim::log::colorless "pre-start has been successfully completed!"
|
||||
@ -119,11 +102,8 @@ if [[ $? -ne 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
openim::log::status "Start the post-start tools:"
|
||||
${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start
|
||||
# ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start
|
||||
openim::log::status "post-start has been successfully completed!"
|
||||
openim::util::find_ports_for_all_services ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}
|
||||
openim::util::find_ports_for_all_services ${OPENIM_MSGTRANSFER_BINARY[@]}
|
||||
|
||||
@ -16,7 +16,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
@ -25,53 +24,56 @@ import (
|
||||
"github.com/openimsdk/open-im-server/v3/tools/component/checks"
|
||||
"github.com/openimsdk/open-im-server/v3/tools/component/util"
|
||||
"github.com/openimsdk/tools/log"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/openimsdk/tools/errs"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/db/s3/minio"
|
||||
)
|
||||
|
||||
const (
|
||||
// defaultCfgPath is the default path of the configuration file.
|
||||
defaultCfgPath = "../../../../../config/config.yaml"
|
||||
maxRetry = 100
|
||||
)
|
||||
const defaultCfgPath = "./config.yaml"
|
||||
const maxRetry = 100
|
||||
|
||||
var (
|
||||
cfgPath = flag.String("c", defaultCfgPath, "Path to the configuration file")
|
||||
)
|
||||
func initConfig(cfgPath string) error {
|
||||
viper.SetConfigType("yaml")
|
||||
viper.AddConfigPath(".")
|
||||
|
||||
func initCfg() (*config.GlobalConfig, error) {
|
||||
data, err := os.ReadFile(*cfgPath)
|
||||
if err != nil {
|
||||
return nil, errs.WrapMsg(err, "ReadFile unmarshal failed")
|
||||
viper.SetConfigName("config")
|
||||
viper.AddConfigPath("../../../../../config")
|
||||
|
||||
viper.SetEnvPrefix("openim")
|
||||
viper.AutomaticEnv()
|
||||
|
||||
if cfgPath != "" {
|
||||
viper.SetConfigFile(cfgPath)
|
||||
} else if envPath, ok := os.LookupEnv("OPENIM_CONFIG"); ok && envPath != "" {
|
||||
viper.SetConfigFile(envPath)
|
||||
}
|
||||
|
||||
conf := config.NewGlobalConfig()
|
||||
err = yaml.Unmarshal(data, &conf)
|
||||
if err != nil {
|
||||
return nil, errs.WrapMsg(err, "InitConfig unmarshal failed")
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
return conf, nil
|
||||
|
||||
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
var cfgFile string
|
||||
pflag.StringVarP(&cfgFile, "config", "c", "", "config file (default is ./config.yaml)")
|
||||
pflag.Parse()
|
||||
|
||||
ctx := context.Background()
|
||||
conf, err := initCfg()
|
||||
if err != nil {
|
||||
|
||||
if err := initConfig(cfgFile); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Initialization failed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := util.ConfigGetEnv(conf); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Environment variable override failed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
// if err := util.ConfigGetEnv(conf); err != nil {
|
||||
// fmt.Fprintf(os.Stderr, "Environment variable override failed: %v\n", err)
|
||||
// os.Exit(1)
|
||||
// }
|
||||
|
||||
// Define a slice of functions to perform each service check
|
||||
serviceChecks := []func(context.Context, *config.GlobalConfig) error{
|
||||
@ -89,11 +91,11 @@ func main() {
|
||||
},
|
||||
}
|
||||
|
||||
if conf.Object.Enable == "minio" {
|
||||
if viper.GetString("object.enable") == "minio" {
|
||||
minioConfig := checks.MinioCheck{
|
||||
Config: minio.Config(conf.Object.Minio),
|
||||
Config: minio.Config(viper.GetString("object.minio")),
|
||||
// UseSSL: conf.Minio.UseSSL,
|
||||
ApiURL: conf.Object.ApiURL,
|
||||
ApiURL: viper.GetString("object.apiURL"),
|
||||
}
|
||||
|
||||
adjustUseSSL(&minioConfig)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user