Skip to content

Commit

Permalink
Merge pull request #345 from bavix/fixes-p6
Browse files Browse the repository at this point in the history
chore: close(ch)
  • Loading branch information
rez1dent3 authored Jul 11, 2024
2 parents 07002d0 + a02aba1 commit 70de1c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func restServe(ctx context.Context, builder *deps.Builder) error {
}

ch := make(chan error)
defer close(ch)

go func() {
zerolog.Ctx(ctx).
Expand Down
3 changes: 2 additions & 1 deletion internal/app/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (s *GRPCServer) Serve(ctx context.Context) error {
}

server, ch := s.newServer(ctx)
defer close(ch)

// Wait for the gRPC server to exit or the context to be done.
select {
Expand All @@ -52,7 +53,7 @@ func (s *GRPCServer) Serve(ctx context.Context) error {
// output is the output directory where the server.go file is located.
// It returns the exec.Cmd object representing the running process, and a channel
// that receives an error when the process exits.
func (s *GRPCServer) newServer(ctx context.Context) (*exec.Cmd, <-chan error) {
func (s *GRPCServer) newServer(ctx context.Context) (*exec.Cmd, chan error) {
// Construct the command to run the gRPC server.
run := exec.CommandContext(ctx, "go", "run", s.params.Output()+"/server.go") //nolint:gosec
run.Env = os.Environ()
Expand Down

0 comments on commit 70de1c2

Please sign in to comment.