Skip to content

Commit

Permalink
feat(fxcore): Added support for listener address (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekkinox committed Apr 5, 2024
1 parent 1a74562 commit 9e092a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/modules/fxcore.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ When you use a Yokai `application template`, you have nothing to install, it's r
modules:
core:
server:
port: 8081 # core http server port (default 8081)
address: ":8081" # core http server listener address (default :8081)
errors:
obfuscate: false # to obfuscate error messages on the core http server responses
stack: false # to add error stack trace to error response of the core http server
Expand Down
2 changes: 1 addition & 1 deletion fxcore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ modules:
type: stdout
core:
server:
port: 8081 # core http server port (default 8081)
address: ":8081" # core http server listener address (default :8081)
errors:
obfuscate: false # to obfuscate error messages on the core http server responses
stack: false # to add error stack trace to error response of the core http server
Expand Down
10 changes: 5 additions & 5 deletions fxcore/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

const (
ModuleName = "core"
DefaultPort = 8081
DefaultAddress = ":8081"
DefaultMetricsPath = "/metrics"
DefaultHealthCheckStartupPath = "/healthz"
DefaultHealthCheckLivenessPath = "/livez"
Expand Down Expand Up @@ -135,13 +135,13 @@ func NewFxCore(p FxCoreParam) (*Core, error) {
// lifecycles
p.LifeCycle.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
port := p.Config.GetInt("modules.core.server.port")
if port == 0 {
port = DefaultPort
address := p.Config.GetString("modules.core.server.address")
if address == "" {
address = DefaultAddress
}

//nolint:errcheck
go coreServer.Start(fmt.Sprintf(":%d", port))
go coreServer.Start(address)

return nil
},
Expand Down

0 comments on commit 9e092a9

Please sign in to comment.