package grpcprocess

import (
	
	

	

	
)

// Server returns a process.Runnable instance for the given gRPC server and
// network listener.
func ( *grpc.Server,  net.Listener) process.Runnable {
	return process.Leaf(
		func( context.Context) error {
			return .Serve()
		},
		func( context.Context) error {
			 := make(chan struct{})
			go func() {
				.GracefulStop()
				close()
			}()
			select {
			case <-.Done():
				// Note that Stop interrupts GracefulStop when
				// called concurrently.
				.Stop()
				<-
			case <-:
			}
			return nil
		},
	)
}