Skip to content

Commit 808102e

Browse files
committed
refactor: move metrics setup code to own function
1 parent 1b14625 commit 808102e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

cmd/main.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ func main() {
2424

2525
webserver := web.NewWebsocketServer(conf.Webserver.ListenAddr, conf.Webserver.ListenPort, conf.Webserver.CertPath, conf.Webserver.CertKeyPath)
2626

27+
setupMetrics(conf, webserver)
28+
29+
go webserver.Start()
30+
31+
watcher := certificatetransparency.Watcher{}
32+
watcher.Start()
33+
}
34+
35+
func setupMetrics(conf config.Config, webserver *web.WebServer) {
2736
if conf.Prometheus.Enabled {
2837
// If prometheus is enabled, and interface is either unconfigured or same as webserver config, use existing webserver
2938
if (conf.Prometheus.ListenAddr == "" || conf.Prometheus.ListenAddr == conf.Webserver.ListenAddr) &&
@@ -37,9 +46,4 @@ func main() {
3746
go metricsServer.Start()
3847
}
3948
}
40-
41-
go webserver.Start()
42-
43-
watcher := certificatetransparency.Watcher{}
44-
watcher.Start()
4549
}

0 commit comments

Comments
 (0)