"sync"
"time"
- "github.com/Sirupsen/logrus"
+ "github.com/sirupsen/logrus"
)
// A Scheduler maps queued containers onto unallocated workers in
runOnce sync.Once
stop chan struct{}
+ stopped chan struct{}
}
// New returns a new unstarted Scheduler.
staleLockTimeout: staleLockTimeout,
queueUpdateInterval: queueUpdateInterval,
stop: make(chan struct{}),
+ stopped: make(chan struct{}),
locking: map[string]bool{},
}
}
// Stop.
func (sch *Scheduler) Stop() {
close(sch.stop)
+ <-sch.stopped
}
func (sch *Scheduler) run() {
+ defer close(sch.stopped)
+
// Ensure the queue is fetched once before attempting anything.
for err := sch.queue.Update(); err != nil; err = sch.queue.Update() {
sch.logger.Errorf("error updating queue: %s", err)