mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-30 10:35:32 +02:00
signal: handle shutdown properly
This addresses issues related to the mobile lnd builds, where calling `stopDaemon` and subsequently calling LndMobile's `Start` results in crash.
This commit is contained in:
10
rpcserver.go
10
rpcserver.go
@ -520,6 +520,9 @@ type rpcServer struct {
|
||||
// extRestRegistrar is optional and specifies the registration
|
||||
// callback to register external REST subservers.
|
||||
extRestRegistrar RestRegistrar
|
||||
|
||||
// interceptor is used to be able to request a shutdown
|
||||
interceptor signal.Interceptor
|
||||
}
|
||||
|
||||
// A compile time check to ensure that rpcServer fully implements the
|
||||
@ -531,7 +534,8 @@ var _ lnrpc.LightningServer = (*rpcServer)(nil)
|
||||
// be used to register the LightningService with the gRPC server.
|
||||
func newRPCServer(cfg *Config, interceptorChain *rpcperms.InterceptorChain,
|
||||
extSubserverCfg *RPCSubserverConfig,
|
||||
extRestRegistrar RestRegistrar) *rpcServer {
|
||||
extRestRegistrar RestRegistrar,
|
||||
interceptor signal.Interceptor) *rpcServer {
|
||||
|
||||
// We go trhough the list of registered sub-servers, and create a gRPC
|
||||
// handler for each. These are used to register with the gRPC server
|
||||
@ -552,6 +556,7 @@ func newRPCServer(cfg *Config, interceptorChain *rpcperms.InterceptorChain,
|
||||
extSubserverCfg: extSubserverCfg,
|
||||
extRestRegistrar: extRestRegistrar,
|
||||
quit: make(chan struct{}, 1),
|
||||
interceptor: interceptor,
|
||||
}
|
||||
}
|
||||
|
||||
@ -5383,8 +5388,7 @@ func (r *rpcServer) GetNetworkInfo(ctx context.Context,
|
||||
// a graceful shutdown of the daemon.
|
||||
func (r *rpcServer) StopDaemon(ctx context.Context,
|
||||
_ *lnrpc.StopRequest) (*lnrpc.StopResponse, error) {
|
||||
|
||||
signal.RequestShutdown()
|
||||
r.interceptor.RequestShutdown()
|
||||
return &lnrpc.StopResponse{}, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user