Skip to content

Commit

Permalink
lnd: initialize an autopilot.Agent instance if set in the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Aug 11, 2017
1 parent ba5ed9e commit ece1d09
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
})

Expand Down

0 comments on commit ece1d09

Please sign in to comment.