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