@@ -24,6 +24,7 @@ import (
2424 "gopkg.in/yaml.v3"
2525
2626 "github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
27+ "github.com/openimsdk/open-im-server/v3/pkg/util/genutil"
2728)
2829
2930//go:embed version
@@ -37,19 +38,30 @@ const (
3738
3839// return absolude path join ../config/, this is k8s container config path.
3940func GetDefaultConfigPath () string {
40- b , err := filepath . Abs ( os .Args [ 0 ] )
41+ executablePath , err := os .Executable ( )
4142 if err != nil {
42- fmt .Println ("filepath.Abs error,err= " , err )
43+ fmt .Println ("GetDefaultConfigPath error: " , err . Error () )
4344 return ""
4445 }
45- return filepath .Join (filepath .Dir (b ), "../config/" )
46+
47+ configPath , err := genutil .OutDir (filepath .Join (filepath .Dir (executablePath ), "../config/" ))
48+ if err != nil {
49+ fmt .Fprintf (os .Stderr , "failed to get output directory: %v\n " , err )
50+ os .Exit (1 )
51+ }
52+ return configPath
4653}
4754
4855// getProjectRoot returns the absolute path of the project root directory.
4956func GetProjectRoot () string {
50- b , _ := filepath . Abs ( os .Args [ 0 ] )
57+ executablePath , _ := os .Executable ( )
5158
52- return filepath .Join (filepath .Dir (b ), "../../../../.." )
59+ projectRoot , err := genutil .OutDir (filepath .Join (filepath .Dir (executablePath ), "../../../../.." ))
60+ if err != nil {
61+ fmt .Fprintf (os .Stderr , "failed to get output directory: %v\n " , err )
62+ os .Exit (1 )
63+ }
64+ return projectRoot
5365}
5466
5567func GetOptionsByNotification (cfg NotificationConf ) msgprocessor.Options {
0 commit comments