Exemple #1
0
func updateEntry(md *cobra.Command, args []string) {
	makeRoot()
	p, err := loadSnapShot("master")
	if err != nil {
		logrus.Warn(err)
		os.Exit(1)
	}

	if concurrent < 1 {
		concurrent = 1
	}
	s := semaphore.NewSemaphore(int(concurrent))
	wg := sync.WaitGroup{}
	wg.Add(len(p.Plugins))
	lock := sync.RWMutex{}
	for i := range p.Plugins {
		go func(i string) {
			s.Acquire(1)
			defer func() {
				s.Release(1)
				wg.Done()
			}()
			lock.RLock()
			pl := p.Plugins[i]
			lock.RUnlock()
			plUp, err := doBundle(pl.Repo, pl.SubPath, true)
			if err != nil {
				logrus.Warn(err)
			}

			lock.Lock()
			defer lock.Unlock()

			p.Plugins[i] = *plUp
		}(i)
	}

	wg.Wait()

	saveSnapShot("master", p)
}
Exemple #2
0
func compileSnapshot(p *Plugins, concurrent uint) {
	wg := sync.WaitGroup{}
	wg.Add(len(p.Plugins))
	// I don't want more than
	s := semaphore.NewSemaphore(int(concurrent))
	for i := range p.Plugins {
		go func(i string) {
			s.Acquire(1)
			defer func() {
				s.Release(1)
				wg.Done()
			}()
			err := checkoutCommit(p.Plugins[i], true)
			if err != nil {
				logrus.Warnf("can not restore state for %s reason is %s", p.Plugins[i].Repo, err.Error())
			}
		}(i)
	}

	wg.Wait()
}