service.go
func Start(repo *Repo) {
	if repo.Interval <= 0 {
		// ignore, don't setup periodic pull.
		Logger().Println("interval too small, periodic pull not enabled.")
		return
	}
	service := &repoService{
		repo,
		gos.NewTicker(repo.Interval),
		make(chan struct{}),
	}
	go func(s *repoService) {
		for {
			select {
			case <-s.ticker.C():
				err := repo.Pull()
				if err != nil {
					Logger().Println(err)
				}
			case <-s.halt:
				s.ticker.Stop()
				return
			}
		}
	}(service)

	// add to services to make it stoppable
	Services.add(service)
}
func Start(repo *Repo) {
	if repo.Interval <= 0 {
		// ignore, don't setup periodic pull.
		Logger().Println("interval too small, periodic pull not enabled.")
		return
	}
	service := &repoService{
		repo,
		gos.NewTicker(repo.Interval),
		make(chan struct{}),
	}
	go func(s *repoService) {
		for {
			select {
			case <-s.ticker.C():
				err := repo.Pull()
				if err != nil {
					Logger().Println(err)
				}
			case <-s.halt:
				s.ticker.Stop()
				return
			}
		}
	}(service)

	// add to services to make it stoppable
	Services.add(service)
}
func Start ( repo * Repo ) { if repo . Interval <= 0 { // ignore, don't setup periodic pull. Logger ( ) . Println ( " " ) return } service := & repoService { repo , gos . NewTicker ( repo . Interval ) , make ( chan struct { } ) , } go func ( s * repoService ) { for { select { case <- s . ticker . C ( ) : err := repo . Pull ( ) if err != nil { Logger ( ) . Println ( err ) } case <- s . halt : s . ticker . Stop ( ) return } } } ( service ) // add to services to make it stoppable Services . add ( service ) }
// Start starts a new background service to pull periodically.
Start starts a new background service to pull periodically .