mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
parent
dae4e9b1ec
commit
41d5c2b652
@ -7,13 +7,13 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Endpoint *EndpointConfig
|
||||
Proxy *ProxyConfig
|
||||
Email *EmailConfig
|
||||
Registration *RegistrationConfig
|
||||
Store *store.Config
|
||||
Ziti *ZitiConfig
|
||||
MetricsConfig *MetricsConfig
|
||||
Endpoint *EndpointConfig
|
||||
Proxy *ProxyConfig
|
||||
Email *EmailConfig
|
||||
Registration *RegistrationConfig
|
||||
Store *store.Config
|
||||
Ziti *ZitiConfig
|
||||
Metrics *MetricsConfig
|
||||
}
|
||||
|
||||
type EndpointConfig struct {
|
||||
|
@ -44,8 +44,14 @@ func Run(cfg *Config) error {
|
||||
return errors.Wrap(err, "error opening store")
|
||||
}
|
||||
|
||||
mtr = newMetricsAgent(cfg.MetricsConfig)
|
||||
go mtr.run()
|
||||
if cfg.Metrics != nil {
|
||||
mtr = newMetricsAgent(cfg.Metrics)
|
||||
go mtr.run()
|
||||
defer func() {
|
||||
mtr.stop()
|
||||
mtr.join()
|
||||
}()
|
||||
}
|
||||
|
||||
server := rest_server_zrok.NewServer(api)
|
||||
defer func() { _ = server.Shutdown() }()
|
||||
|
@ -2,11 +2,11 @@ package controller
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MetricsConfig struct {
|
||||
Influx *InfluxConfig
|
||||
ServiceName string
|
||||
Influx *InfluxConfig
|
||||
}
|
||||
|
||||
type InfluxConfig struct {
|
||||
@ -17,18 +17,31 @@ type InfluxConfig struct {
|
||||
}
|
||||
|
||||
type metricsAgent struct {
|
||||
cfg *MetricsConfig
|
||||
cfg *MetricsConfig
|
||||
shutdown chan struct{}
|
||||
joined chan struct{}
|
||||
}
|
||||
|
||||
func newMetricsAgent(cfg *MetricsConfig) *metricsAgent {
|
||||
return &metricsAgent{cfg: cfg}
|
||||
return &metricsAgent{
|
||||
cfg: cfg,
|
||||
shutdown: make(chan struct{}),
|
||||
joined: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (mtr *metricsAgent) run() {
|
||||
logrus.Info("starting")
|
||||
defer logrus.Info("exiting")
|
||||
defer close(mtr.joined)
|
||||
|
||||
for {
|
||||
time.Sleep(24 * time.Hour)
|
||||
}
|
||||
<-mtr.shutdown
|
||||
}
|
||||
|
||||
func (mtr *metricsAgent) stop() {
|
||||
close(mtr.shutdown)
|
||||
}
|
||||
|
||||
func (mtr *metricsAgent) join() {
|
||||
<-mtr.joined
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user