Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close not working properly on gRPC graceful stop #89

Open
elvizlai opened this issue Jul 25, 2021 · 1 comment
Open

Close not working properly on gRPC graceful stop #89

elvizlai opened this issue Jul 25, 2021 · 1 comment

Comments

@elvizlai
Copy link

elvizlai commented Jul 25, 2021

example code:

package main

import (
	"fmt"
	"net"
	"os"
	"os/signal"
	"syscall"
	"time"

	"github.com/soheilhy/cmux"
	"google.golang.org/grpc"
)

func main() {
	lis, err := net.Listen("tcp", ":8080")
	if err != nil {
		panic(err)
	}

	mux := cmux.New(lis)
	grpcL := mux.Match(cmux.HTTP2HeaderField("content-type", "application/grpc"))
	_ = grpcL

	s := grpc.NewServer()
	// xxx.RegisterXXXServiceServer(s, XXXIMPL)

	go func() {
		// FIXME: using muxed grpcL here can not graceful stop
		err = s.Serve(lis)
		fmt.Println(err)
	}()

	fmt.Println("wait for sig")
	c := make(chan os.Signal, 1)
	signal.Notify(c, []os.Signal{syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT}...)
	<-c

        // FIXME: hangs on when start server with grpcL
	s.GracefulStop()

	fmt.Println("stopped")
	time.Sleep(time.Second * 1)
}

@jgraettinger
Copy link

See #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants