lnd: initialize an autopilot.Agent instance if set in the config file
This commit is contained in:
parent
ba5ed9e8d2
commit
ece1d09a9f
23
lnd.go
23
lnd.go
@ -19,6 +19,7 @@ import (
|
||||
|
||||
flags "github.com/btcsuite/go-flags"
|
||||
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/lightningnetwork/lnd/autopilot"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
@ -286,11 +287,33 @@ func lndMain() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Now that the server has started, if the autopilot mode is currently
|
||||
// active, then we'll initialize a fresh instance of it and start it.
|
||||
var pilot *autopilot.Agent
|
||||
if cfg.Autopilot.Active {
|
||||
pilot, err := initAutoPilot(server, cfg.Autopilot)
|
||||
if err != nil {
|
||||
ltndLog.Errorf("unable to create autopilot agent: %v",
|
||||
err)
|
||||
return err
|
||||
}
|
||||
if err := pilot.Start(); err != nil {
|
||||
ltndLog.Errorf("unable to start autopilot agent: %v",
|
||||
err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
addInterruptHandler(func() {
|
||||
ltndLog.Infof("Gracefully shutting down the server...")
|
||||
rpcServer.Stop()
|
||||
fundingMgr.Stop()
|
||||
server.Stop()
|
||||
|
||||
if pilot != nil {
|
||||
pilot.Stop()
|
||||
}
|
||||
|
||||
server.WaitForShutdown()
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user