// Wait for a process to exit
Wait for a process to exit
// Wait for a process to exit
func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (_ *taskAPI.WaitResponse, err error) {
	var ret uint32
	start := time.Now()
	defer func() {
		err = toGRPC(err)
		rpcDurationsHistogram.WithLabelValues("wait").Observe(float64(time.Since(start).Nanoseconds() / int64(time.Millisecond)))
	}()
	s.mu.Lock()
	c, err := s.getContainer(r.ID)
	s.mu.Unlock()
	if err != nil {
		return nil, err
	}
	if r.ExecID == "" {
		ret = <-c.exitCh
		c.exitCh <- ret
	} else { 
		execs, err := c.getExec(r.ExecID)
		if err != nil {
			return nil, err
		}
		ret = <-execs.exitCh
		execs.exitCh <- ret
	}
	return &taskAPI.WaitResponse{
		ExitStatus: ret,
		ExitedAt:   c.exitTime,
	}, nil
}
func ( s * service ) Wait ( ctx context . Context , r * taskAPI . WaitRequest ) ( _ * taskAPI . WaitResponse , err error ) { var ret uint32 start := time . Now ( ) defer func ( ) { err = toGRPC ( err ) rpcDurationsHistogram . WithLabelValues ( " " ) . Observe ( float64 ( time . Since ( start ) . Nanoseconds ( ) / int64 ( time . Millisecond ) ) ) } ( ) s . mu . Lock ( ) c , err := s . getContainer ( r . ID ) s . mu . Unlock ( ) if err != nil { return nil , err } if r . ExecID == " " { ret = <- c . exitCh c . exitCh <- ret } else { execs , err := c . getExec ( r . ExecID ) if err != nil { return nil , err } ret = <- execs . exitCh execs . exitCh <- ret } return & taskAPI . WaitResponse { ExitStatus : ret , ExitedAt : c . exitTime , } , nil }
Wait for a process to exit
Wait for a process to exit
//wait for container // refill the exitCh with the container process's exit code in case // there were other waits on this process. //wait for exec // refill the exitCh with the exec process's exit code in case // there were other waits on this process.