Skip to content

Commit

Permalink
Support a custom host for health server
Browse files Browse the repository at this point in the history
Instead of forcing to listen on all interfaces we should give the possibility for the user to make the health server listen on a specific host/ip.
  • Loading branch information
renan committed Apr 20, 2018
1 parent 6fac369 commit 97294f2
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 97294f2

Please sign in to comment.