Retrieve ctr missed events once connection is re-established

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-03-22 10:38:47 -07:00
parent 142e22a4dc
commit 2b8ae55b0b

View file

@ -568,13 +568,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))