Ejemplo n.º 1
0
func main() {
	log.Info("Starting docker_events")
	pub := logyard.Broker.NewPublisherMust()
	defer pub.Stop()

	server.MarkRunning("docker_events")

	for event := range docker_events.Stream() {
		SendToLogyard(pub, event)
	}
}
Ejemplo n.º 2
0
func (l *dockerListener) Listen() {
	for evt := range docker_events.Stream() {
		id := evt.Id[:ID_LENGTH]
		if len(id) != ID_LENGTH {
			common.Fatal("Invalid docker ID length: %v (orig: %v)", len(id), len(evt.Id))
		}

		// Notify container stop events by closing the appropriate ch.
		if !(evt.Status == "die" || evt.Status == "kill") {
			continue
		}
		l.mux.Lock()
		if ch, ok := l.waiters[id]; ok {
			close(ch)
			delete(l.waiters, id)
		}
		l.mux.Unlock()
	}
}