Skip to content

Commit

Permalink
fix: application
Browse files Browse the repository at this point in the history
  • Loading branch information
yusank committed Jun 5, 2022
1 parent cc991f8 commit 9823115
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions pkg/app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/go-kratos/kratos/v2/transport/http"
redisv8 "github.com/go-redis/redis/v8"

"github.com/go-goim/core/pkg/cmd"
"github.com/go-goim/core/pkg/config"
"github.com/go-goim/core/pkg/db/mysql"
"github.com/go-goim/core/pkg/db/redis"
Expand Down Expand Up @@ -65,6 +66,14 @@ func WithMetadata(k, v string) Option {
}
}

var (
useHostIP bool
)

func init() {
cmd.GlobalFlagSet.BoolVar(&useHostIP, "use-host-ip", true, "use host ip")
}

var (
initFlag atomic.Bool
)
Expand Down Expand Up @@ -128,6 +137,11 @@ func InitApplication(opts ...Option) (*Application, error) {
}

func (a *Application) initHost() error {
if !useHostIP {
a.host = ""
return nil
}

addrs, err := net.InterfaceAddrs()
if err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ func InitConfig() *Config {
panic(err)
}

log.Debug("service content", "service", cfg)

cfg.SrvConfig = sc
log.Debug("service content", "service", cfg)
}

setLogger(cfg.SrvConfig.Name, cfg.SrvConfig.Log)
Expand Down

0 comments on commit 9823115

Please sign in to comment.