diff --git a/cmd/servicechecker/main.go b/cmd/servicechecker/main.go index 2904b19..52265ea 100644 --- a/cmd/servicechecker/main.go +++ b/cmd/servicechecker/main.go @@ -41,17 +41,22 @@ func main() { } l.Info(ctx, "scheduler: create") - s, err := scheduler.NewScheduler() + sch, err := scheduler.NewScheduler() if err != nil { l.Fatal(ctx, "failed to create scheduler", err) } l.Info(ctx, "scheduler: created") l.Info(ctx, "scheduler: try to start") - if err = s.Start(); err != nil { + if err = sch.Start(); err != nil { l.Fatal(ctx, "failed to start scheduler", err) } l.Info(ctx, "scheduler: starting") + defer func() { + if err = sch.Stop(); err != nil { + l.Error(ctx, "failed to stop scheduler", err) + } + }() clients := make(map[string]client.Client) gcli := grpccli.NewClient( @@ -117,7 +122,7 @@ func main() { treq := c.NewRequest(pkg, svc+"."+mth, req) - s.NewJob(time.Duration(check.Interval), func() { + sch.NewJob(time.Duration(check.Interval), func() { labels := []string{"check", check.Name, "task", task.Name, "service", svc, "endpoint", mth} m.Counter(semconv.ClientRequestInflight, labels...).Inc() ts := time.Now() @@ -140,4 +145,5 @@ func main() { } <-ctx.Done() + l.Info(ctx, "exiting") }