Skip to content

Commit

Permalink
Introduce PULUMI_DEBUG_GRPC support
Browse files Browse the repository at this point in the history
  • Loading branch information
t0yv0 committed Nov 8, 2022
1 parent 3e12811 commit e21da21
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pulumi-language-dotnet/main.go
Expand Up @@ -106,22 +106,24 @@ func main() {
}

// Fire up a gRPC server, letting the kernel choose a free port.
port, done, err := rpcutil.Serve(0, cancelChannel, []func(*grpc.Server) error{
func(srv *grpc.Server) error {
handle, err := rpcutil.ServeWithOptions(rpcutil.ServeOptions{
Cancel: cancelChannel,
Init: func(srv *grpc.Server) error {
host := newLanguageHost(dotnetExec, engineAddress, tracing, binary)
pulumirpc.RegisterLanguageRuntimeServer(srv, host)
return nil
},
}, nil)
Options: rpcutil.OpenTracingServerInterceptorOptions(nil),
})
if err != nil {
cmdutil.Exit(errors.Wrapf(err, "could not start language host RPC server"))
}

// Otherwise, print out the port so that the spawner knows how to reach us.
fmt.Printf("%d\n", port)
fmt.Printf("%d\n", handle.Port)

// And finally wait for the server to stop serving.
if err := <-done; err != nil {
if err := <-handle.Done; err != nil {
cmdutil.Exit(errors.Wrapf(err, "language host RPC stopped serving"))
}
}
Expand Down

0 comments on commit e21da21

Please sign in to comment.