// Exec an additional process inside the container
Exec an additional process inside the container
// Exec an additional process inside the container
func (s *service) Exec(ctx context.Context, r *taskAPI.ExecProcessRequest) (_ *ptypes.Empty, err error) {
	start := time.Now()
	defer func() {
		rpcDurationsHistogram.WithLabelValues("exec").Observe(float64(time.Since(start).Nanoseconds() / int64(time.Millisecond)))
		err = toGRPC(err)
	}()
	s.mu.Lock()
	defer s.mu.Unlock()
	c, err := s.getContainer(r.ID)
	if err != nil {
		return nil, err
	}
	if execs := c.execs[r.ExecID]; execs != nil {
		return nil, errdefs.ToGRPCf(errdefs.ErrAlreadyExists, "id %s", r.ExecID)
	}
	execs, err := newExec(c, r.Stdin, r.Stdout, r.Stderr, r.Terminal, r.Spec)
	if err != nil {
		return nil, errdefs.ToGRPC(err)
	}
	c.execs[r.ExecID] = execs
	s.send(&eventstypes.TaskExecAdded{
		ContainerID: c.id,
		ExecID:      r.ExecID,
	})
	return empty, nil
}
func ( s * service ) Exec ( ctx context . Context , r * taskAPI . ExecProcessRequest ) ( _ * ptypes . Empty , err error ) { start := time . Now ( ) defer func ( ) { rpcDurationsHistogram . WithLabelValues ( " " ) . Observe ( float64 ( time . Since ( start ) . Nanoseconds ( ) / int64 ( time . Millisecond ) ) ) err = toGRPC ( err ) } ( ) s . mu . Lock ( ) defer s . mu . Unlock ( ) c , err := s . getContainer ( r . ID ) if err != nil { return nil , err } if execs := c . execs [ r . ExecID ] ; execs != nil { return nil , errdefs . ToGRPCf ( errdefs . ErrAlreadyExists , " " , r . ExecID ) } execs , err := newExec ( c , r . Stdin , r . Stdout , r . Stderr , r . Terminal , r . Spec ) if err != nil { return nil , errdefs . ToGRPC ( err ) } c . execs [ r . ExecID ] = execs s . send ( & eventstypes . TaskExecAdded { ContainerID : c . id , ExecID : r . ExecID , } ) return empty , nil }
Exec an additional process inside the container
Exec an additional process inside the container