I'm migrating an existing http application to a GRPC based application. For some time, both grpc and http will be running on different ports in the same go file, and I'll be moving the existing the http server part into a goroutine. This is how it would look like.
main() {
//Move existing server into a goroutine
go func() {
s.server, err = chttp.NewHTTPSServer("443", s.certPath, s.keyPath, s.Router, s.options)
if err != nil {
log.Fatalf("server: error creating HTTP server - %v\n", err)
}
if err := s.server.Serve(); err != http.ErrServerClosed {
log.Fatalf("server: run error - %v\n", err)
}
}
// Add new grpc server
lis, err := net.Listen("tcp", ":8433")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
a := grpc.NewServer()
pb.RegisterNewServer(a, &test.GrpcServer{})
if err := a.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}
Could this cause any issues, can grpc, http server be run simultaneously from the same program? I'm not sure if it could cause some issues I'm not aware of.