Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- srv := &http.Server{
- Addr: fmt.Sprintf(":%s", configData.DashboardPort),
- Handler: dashboardweb.New(logger, dashbaordService).Router(),
- }
- var g errgroup.Group
- // g.Go(grpcServer.Serve)
- g.Go(func() error {
- listener, err := net.Listen("tcp", fmt.Sprintf(":%s", configData.PORT))
- if err != nil {
- return errors.Wrap(err, "failed to listen: %v")
- }
- defer listener.Close()
- logger.Log("port", configData.PORT, "gRPC server port")
- return grpcSrv.Serve(listener)
- })
- g.Go(func() error {
- logger.Log("port", configData.DashboardPort, "http server port")
- return srv.ListenAndServe()
- })
- go func() {
- quit := make(chan os.Signal)
- signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
- <-quit
- logger.Log("Shutting down all services... 😔")
- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
- defer cancel()
- if err := srv.Shutdown(ctx); err != nil {
- logger.Log("Server Shutdown:", err, "error shutting down")
- }
- grpcSrv.GracefulStop()
- }()
- logger.Log("starting gRPC and HTTP server")
- err = g.Wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement