diff --git a/pkg/watcher/coach.go b/pkg/watcher/coach.go index ecb1718..ae579aa 100644 --- a/pkg/watcher/coach.go +++ b/pkg/watcher/coach.go @@ -40,7 +40,9 @@ func (c *CoachOutlet) SetOption(cfg model.WatchInfo) { } func (c *CoachOutlet) Cancel() { - c.cancel() + if c.cancel != nil { + c.cancel() + } } func (c *CoachOutlet) Restart() { diff --git a/pkg/watcher/controller.go b/pkg/watcher/controller.go index 20c88fa..8c8528f 100644 --- a/pkg/watcher/controller.go +++ b/pkg/watcher/controller.go @@ -127,7 +127,7 @@ func (c *Controller) List(req ListWatcherInfoRequest) (resp web.ListResponse[mod } offset := (req.Page - 1) * req.Size - if err = tx.Order("created_at desc").Limit(req.Size).Offset(offset). + if err = tx.Order("created_at desc").Limit(req.Size).Offset(offset).Preload("Pushers"). Find(&resp.List).Error; err != nil { return resp, fmt.Errorf("查询列表失败:%v", err) } @@ -146,7 +146,7 @@ func (c *Controller) Delete(uid string) error { func (c *Controller) Stop(uid string) error { c.lock.RLock() - if watcher, ok := c.m[uid]; ok { + if watcher, ok := c.m[uid]; ok && watcher != nil { watcher.Cancel() } c.lock.RUnlock()