Fix snapshotter initialization and remove initial snapshot on startup
- Remove immediate snapshot when periodic goroutine starts - Fix variable shadowing issue in snapshotter creation - Add debug logging for snapshotter shutdown - Snapshots now only occur after 10 minutes or on shutdown
This commit is contained in:
parent
ae2ef2ae0c
commit
52cdcd5785
@ -73,12 +73,12 @@ func New(deps Dependencies) *RouteWatch {
|
||||
|
||||
// Create snapshotter unless disabled (for tests)
|
||||
if os.Getenv("ROUTEWATCH_DISABLE_SNAPSHOTTER") != "1" {
|
||||
snapshotter, err := snapshotter.New(deps.RoutingTable, deps.Logger)
|
||||
snap, err := snapshotter.New(deps.RoutingTable, deps.Logger)
|
||||
if err != nil {
|
||||
deps.Logger.Error("Failed to create snapshotter", "error", err)
|
||||
// Continue without snapshotter
|
||||
} else {
|
||||
rw.snapshotter = snapshotter
|
||||
rw.snapshotter = snap
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,9 +153,12 @@ func (rw *RouteWatch) Run(ctx context.Context) error {
|
||||
|
||||
// Take final snapshot before shutdown if snapshotter is available
|
||||
if rw.snapshotter != nil {
|
||||
rw.logger.Info("Shutting down snapshotter")
|
||||
if err := rw.snapshotter.Shutdown(); err != nil {
|
||||
rw.logger.Error("Failed to shutdown snapshotter", "error", err)
|
||||
}
|
||||
} else {
|
||||
rw.logger.Info("No snapshotter available")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -115,11 +115,7 @@ func (s *Snapshotter) periodicSnapshot() {
|
||||
ticker := time.NewTicker(snapshotInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
// Take an initial snapshot
|
||||
if err := s.TakeSnapshot(); err != nil {
|
||||
s.logger.Error("Failed to take initial snapshot", "error", err)
|
||||
}
|
||||
|
||||
// Wait for the first interval before taking any snapshots
|
||||
for {
|
||||
select {
|
||||
case <-s.ctx.Done():
|
||||
|
Loading…
Reference in New Issue
Block a user