Skip to content

Commit

Permalink
Merge pull request #140 from renan/HealthServer_SupportCustomHost
Browse files Browse the repository at this point in the history
Health server support custom host
  • Loading branch information
fasaxc authored Apr 20, 2018
2 parents 6fac369 + 97294f2 commit 7a1d2b6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pkg/config/config_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ type Config struct {
LogSeverityScreen string `config:"oneof(DEBUG,INFO,WARNING,ERROR,CRITICAL);INFO"`
LogSeveritySys string `config:"oneof(DEBUG,INFO,WARNING,ERROR,CRITICAL);INFO"`

HealthEnabled bool `config:"bool;false"`
HealthPort int `config:"int(0,65535);9098"`
HealthEnabled bool `config:"bool;false"`
HealthHost string `config:"string;localhost"`
HealthPort int `config:"int(0,65535);9098"`

PrometheusMetricsEnabled bool `config:"bool;false"`
PrometheusMetricsPort int `config:"int(0,65535);9093"`
PrometheusGoMetricsEnabled bool `config:"bool;true"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/config_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ var _ = DescribeTable("Config parsing",
Entry("LogSeveritySys", "LogSeveritySys", "error", "ERROR"),
Entry("LogSeveritySys", "LogSeveritySys", "critical", "CRITICAL"),

Entry("HealthEnabled", "HealthEnabled", "true", true),
Entry("HealthHost", "HealthHost", "127.0.0.1", "127.0.0.1"),
Entry("HealthPort", "HealthPort", "1234", int(1234)),

Entry("PrometheusMetricsEnabled", "PrometheusMetricsEnabled", "true", true),
Entry("PrometheusMetricsPort", "PrometheusMetricsPort", "1234", int(1234)),
Entry("PrometheusGoMetricsEnabled", "PrometheusGoMetricsEnabled", "false", false),
Expand Down
7 changes: 5 additions & 2 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,11 @@ func (t *TyphaDaemon) Start(cxt context.Context) {
}

if t.ConfigParams.HealthEnabled {
log.WithField("port", t.ConfigParams.HealthPort).Info("Health enabled. Starting server.")
t.healthAggregator.ServeHTTP(t.ConfigParams.HealthEnabled, "", t.ConfigParams.HealthPort)
log.WithFields(log.Fields{
"host": t.ConfigParams.HealthHost,
"port": t.ConfigParams.HealthPort,
}).Info("Health enabled. Starting server.")
t.healthAggregator.ServeHTTP(t.ConfigParams.HealthEnabled, t.ConfigParams.HealthHost, t.ConfigParams.HealthPort)
}
}

Expand Down

0 comments on commit 7a1d2b6

Please sign in to comment.