mirror of
https://github.com/fosrl/newt.git
synced 2026-05-05 23:50:10 -05:00
Fix crashing when removing hc
This commit is contained in:
@@ -250,7 +250,7 @@ func (m *Monitor) RemoveTarget(id int) error {
|
||||
|
||||
// Notify callback of status change
|
||||
if m.callback != nil {
|
||||
go m.callback(m.GetTargets())
|
||||
go m.callback(m.getAllTargetsUnsafe())
|
||||
}
|
||||
|
||||
logger.Info("Successfully removed target %d", id)
|
||||
@@ -283,7 +283,7 @@ func (m *Monitor) RemoveTargets(ids []int) error {
|
||||
|
||||
// Notify callback of status change if any targets were removed
|
||||
if len(notFound) != len(ids) && m.callback != nil {
|
||||
go m.callback(m.GetTargets())
|
||||
go m.callback(m.getAllTargetsUnsafe())
|
||||
}
|
||||
|
||||
if len(notFound) > 0 {
|
||||
@@ -583,7 +583,7 @@ func (m *Monitor) DisableTarget(id int) error {
|
||||
|
||||
// Notify callback of status change
|
||||
if m.callback != nil {
|
||||
go m.callback(m.GetTargets())
|
||||
go m.callback(m.getAllTargetsUnsafe())
|
||||
}
|
||||
} else {
|
||||
logger.Debug("Target %d is already disabled", id)
|
||||
|
||||
2
main.go
2
main.go
@@ -542,7 +542,7 @@ func runNewtMain(ctx context.Context) {
|
||||
if telErr != nil {
|
||||
logger.Warn("Telemetry init failed: %v", telErr)
|
||||
}
|
||||
if tel != nil {
|
||||
if tel != nil && (metricsEnabled || pprofEnabled) {
|
||||
// Admin HTTP server (exposes /metrics when Prometheus exporter is enabled)
|
||||
logger.Debug("Starting metrics server on %s", tcfg.AdminAddr)
|
||||
mux := http.NewServeMux()
|
||||
|
||||
Reference in New Issue
Block a user