Merge pull request #151 from mlaventure/ctr-retrieve-missed-events

Retrieve ctr missed events once connection is re-established
This commit is contained in:
Michael Crosby 2016-03-24 16:57:18 -07:00
commit a06dec80cd

View file

@ -577,13 +577,15 @@ var updateCommand = cli.Command{
} }
func waitForExit(c types.APIClient, events types.API_EventsClient, id, pid string, closer func()) { func waitForExit(c types.APIClient, events types.API_EventsClient, id, pid string, closer func()) {
timestamp := uint64(time.Now().Unix())
for { for {
e, err := events.Recv() e, err := events.Recv()
if err != nil { if err != nil {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
events, _ = c.Events(netcontext.Background(), &types.EventsRequest{}) events, _ = c.Events(netcontext.Background(), &types.EventsRequest{Timestamp: timestamp})
continue continue
} }
timestamp = e.Timestamp
if e.Id == id && e.Type == "exit" && e.Pid == pid { if e.Id == id && e.Type == "exit" && e.Pid == pid {
closer() closer()
os.Exit(int(e.Status)) os.Exit(int(e.Status))