Exemple #1
0
func watchEvents(c *cli.Context) {
	var err error
	dockerClient, err = dockeraction.GetDefaultActionClient()
	if err != nil {
		log.Fatal(err)
	}
	token := c.String("token")

	eventChan := make(chan *docker.APIEvents)
	log.Println("Watching for Docker events")
	if err := dockerClient.AddEventListener(eventChan); err != nil {
		log.Fatal(err)
	}

	for event := range eventChan {
		if event.Status == "start" {
			skip := false
			for _, i := range c.StringSlice("ignore") {
				if i == event.From {
					skip = true
					break
				}
			}
			if !skip {
				go logContainer(event.ID[:12], token)
				log.Printf("Log stream for %s started (%s)", event.ID[:12], event.From)
			}
		}
	}
}
Exemple #2
0
func init() {
	logger = log.New()
	h, err := os.Hostname()
	if err != nil {
		logger.Fatal(err)
	}
	myHostname = h
	baseKey = "network/weave/" + myHostname + "/"
	dockerClient, err = dockeraction.GetDefaultActionClient()
	if err != nil {
		logger.Error(err)
	}
}