mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-11 23:47:32 +08:00
fix: fix openim config path
Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com>
This commit is contained in:
parent
a710bbe4c1
commit
ab2ac119d2
3
.github/workflows/bot-cherry-pick.yml
vendored
3
.github/workflows/bot-cherry-pick.yml
vendored
@ -19,7 +19,8 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
cherry-pick:
|
cherry-pick:
|
||||||
name: Cherry Pick
|
name: Cherry Pick
|
||||||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick') && github.event.comment.user.login=='kubbot'
|
# && github.event.comment.user.login=='kubbot'
|
||||||
|
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the latest code
|
- name: Checkout the latest code
|
||||||
|
|||||||
@ -91,12 +91,14 @@ func (rc *RootCmd) applyOptions(opts ...func(*CmdOpts)) *CmdOpts {
|
|||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(cmdOpts)
|
opt(cmdOpts)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmdOpts
|
return cmdOpts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RootCmd) initializeLogger(cmdOpts *CmdOpts) error {
|
func (rc *RootCmd) initializeLogger(cmdOpts *CmdOpts) error {
|
||||||
logConfig := config.Config.Log
|
logConfig := config.Config.Log
|
||||||
return log.InitFromConfig(
|
return log.InitFromConfig(
|
||||||
|
|
||||||
cmdOpts.loggerPrefixName,
|
cmdOpts.loggerPrefixName,
|
||||||
rc.Name,
|
rc.Name,
|
||||||
logConfig.RemainLogLevel,
|
logConfig.RemainLogLevel,
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
||||||
@ -37,11 +36,7 @@ const (
|
|||||||
|
|
||||||
// getProjectRoot returns the absolute path of the project root directory
|
// getProjectRoot returns the absolute path of the project root directory
|
||||||
func GetProjectRoot() string {
|
func GetProjectRoot() string {
|
||||||
// Program counter (PC): This represents the address of the function.
|
b, _ := filepath.Abs(os.Args[0])
|
||||||
// File path: The full path to the source file from which the function was called. (pkg/common/config/parse.go)
|
|
||||||
// Line number: The line number in the source file from which the function was called.
|
|
||||||
// Success flag: it will be true if the information was successfully fetched, false otherwise.
|
|
||||||
_, b, _, _ := runtime.Caller(0)
|
|
||||||
|
|
||||||
return filepath.Join(filepath.Dir(b), "../../..")
|
return filepath.Join(filepath.Dir(b), "../../..")
|
||||||
}
|
}
|
||||||
@ -64,7 +59,6 @@ func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options {
|
|||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func initConfig(config interface{}, configName, configFolderPath string) error {
|
func initConfig(config interface{}, configName, configFolderPath string) error {
|
||||||
configFolderPath = filepath.Join(configFolderPath, configName)
|
configFolderPath = filepath.Join(configFolderPath, configName)
|
||||||
_, err := os.Stat(configFolderPath)
|
_, err := os.Stat(configFolderPath)
|
||||||
@ -86,17 +80,18 @@ func initConfig(config interface{}, configName, configFolderPath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func InitConfig(configFolderPath string) error {
|
func InitConfig(configFolderPath string) error {
|
||||||
if configFolderPath == "" {
|
if configFolderPath == "" {
|
||||||
envConfigPath := os.Getenv("OPENIMCONFIG")
|
envConfigPath := os.Getenv("OPENIMCONFIG")
|
||||||
if envConfigPath != "" {
|
if envConfigPath != "" {
|
||||||
configFolderPath = envConfigPath
|
configFolderPath = envConfigPath
|
||||||
} else {
|
} else {
|
||||||
configFolderPath = DefaultFolderPath
|
configFolderPath = DefaultFolderPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := initConfig(&Config, FileName, configFolderPath); err != nil {
|
if err := initConfig(&Config, FileName, configFolderPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return initConfig(&Config.Notification, NotificationFileName, configFolderPath)
|
return initConfig(&Config.Notification, NotificationFileName, configFolderPath)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user