Skip to content

Instantly share code, notes, and snippets.

@ziozzang
Created June 18, 2015 05:31
Show Gist options
  • Save ziozzang/ca862cc31fa78ee3d546 to your computer and use it in GitHub Desktop.
Save ziozzang/ca862cc31fa78ee3d546 to your computer and use it in GitHub Desktop.
wait until for new docker event.
/*
* Code by Jioh L. Jung (ziozzang@gmail.com)
* This code is for wait until "new docker event comming..."
* just do exit when new event comming.
* how to build by docker
* $ docker run -v /opt/wait/:/opt/wait/ -i -t google/golang \
/bin/bash -c "cd /opt/wait/ && go get github.com/samalba/dockerclient && go build"
*/
package main
import (
"github.com/samalba/dockerclient"
"time"
"os"
)
func eventCallback(event *dockerclient.Event, ec chan error, args ...interface{}) {
os.Exit(0)
}
func main() {
docker, _ := dockerclient.NewDockerClient("unix:///var/run/docker.sock", nil)
docker.StartMonitorEvents(eventCallback, nil)
time.Sleep(3600 * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment