improved ledger account discovery
This commit is contained in:
@@ -52,10 +52,6 @@ func (i *Imp) startMetrics(cfg *metricsConfig) {
|
||||
ReadHeaderTimeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
if healthRouter != nil {
|
||||
healthRouter.SetStatus(health.SSRunning)
|
||||
}
|
||||
|
||||
go func() {
|
||||
i.logger.Info("Prometheus endpoint listening", zap.String("address", address))
|
||||
if err := i.metricsSrv.Serve(listener); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
@@ -83,3 +79,10 @@ func (i *Imp) shutdownMetrics(ctx context.Context) {
|
||||
}
|
||||
i.metricsSrv = nil
|
||||
}
|
||||
|
||||
func (i *Imp) setMetricsStatus(status health.ServiceStatus) {
|
||||
if i == nil || i.metricsHealth == nil {
|
||||
return
|
||||
}
|
||||
i.metricsHealth.SetStatus(status)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/api/routers/health"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -46,12 +47,14 @@ func (i *Imp) Start() error {
|
||||
|
||||
if err := i.startDiscovery(cfg); err != nil {
|
||||
i.stopDiscovery()
|
||||
i.setMetricsStatus(health.SSTerminating)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), i.shutdownTimeout())
|
||||
i.shutdownMetrics(ctx)
|
||||
cancel()
|
||||
return err
|
||||
}
|
||||
|
||||
i.setMetricsStatus(health.SSRunning)
|
||||
i.logger.Info("Discovery service ready", zap.String("messaging_driver", messagingDriver))
|
||||
|
||||
<-i.stopCh
|
||||
|
||||
Reference in New Issue
Block a user