diff --git a/.github/workflows/bot-cherry-pick.yml b/.github/workflows/bot-cherry-pick.yml index ab8993540..e488e97de 100644 --- a/.github/workflows/bot-cherry-pick.yml +++ b/.github/workflows/bot-cherry-pick.yml @@ -19,7 +19,8 @@ on: jobs: 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 steps: - name: Checkout the latest code diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go index c403768eb..d43f9c078 100644 --- a/pkg/common/cmd/root.go +++ b/pkg/common/cmd/root.go @@ -91,12 +91,14 @@ func (rc *RootCmd) applyOptions(opts ...func(*CmdOpts)) *CmdOpts { for _, opt := range opts { opt(cmdOpts) } + return cmdOpts } func (rc *RootCmd) initializeLogger(cmdOpts *CmdOpts) error { logConfig := config.Config.Log return log.InitFromConfig( + cmdOpts.loggerPrefixName, rc.Name, logConfig.RemainLogLevel, diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 6f3d27b9c..e37514ecd 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -19,7 +19,6 @@ import ( "fmt" "os" "path/filepath" - "runtime" "github.com/OpenIMSDK/protocol/constant" "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor" @@ -37,11 +36,7 @@ const ( // getProjectRoot returns the absolute path of the project root directory func GetProjectRoot() string { - // Program counter (PC): This represents the address of the function. - // 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) + b, _ := filepath.Abs(os.Args[0]) return filepath.Join(filepath.Dir(b), "../../..") } @@ -64,7 +59,6 @@ func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options { return opts } - func initConfig(config interface{}, configName, configFolderPath string) error { configFolderPath = filepath.Join(configFolderPath, configName) _, err := os.Stat(configFolderPath) @@ -86,17 +80,18 @@ func initConfig(config interface{}, configName, configFolderPath string) error { } func InitConfig(configFolderPath string) error { - if configFolderPath == "" { - envConfigPath := os.Getenv("OPENIMCONFIG") - if envConfigPath != "" { - configFolderPath = envConfigPath - } else { - configFolderPath = DefaultFolderPath - } - } + if configFolderPath == "" { + envConfigPath := os.Getenv("OPENIMCONFIG") + if envConfigPath != "" { + configFolderPath = envConfigPath + } else { + configFolderPath = DefaultFolderPath + } + } if err := initConfig(&Config, FileName, configFolderPath); err != nil { return err } + return initConfig(&Config.Notification, NotificationFileName, configFolderPath) }