mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
terminal: start the webserver as soon as possible
Since all the relevant dependancies have been accouted for, we know move the starting of the main webserver to earlier on in the Run function. This is in preparation for later when the webserver will be "always-on" and will be used to server status information about the rest of the LiT subservers.
This commit is contained in:
parent
7166877c06
commit
30262f2ac1
1 changed files with 29 additions and 24 deletions
53
terminal.go
53
terminal.go
|
|
@ -238,15 +238,31 @@ func (g *LightningTerminal) Run() error {
|
|||
return fmt.Errorf("could not create permissions manager")
|
||||
}
|
||||
|
||||
// Construct the rpcProxy. It must be initialised before the main web
|
||||
// server is started.
|
||||
g.rpcProxy = newRpcProxy(g.cfg, g, g.validateSuperMacaroon, g.permsMgr)
|
||||
|
||||
// Start the main web server that dispatches requests either to the
|
||||
// static UI file server or the RPC proxy. This makes it possible to
|
||||
// unlock lnd through the UI.
|
||||
if err := g.startMainWebServer(); err != nil {
|
||||
return fmt.Errorf("error starting main proxy HTTP server: %v",
|
||||
err)
|
||||
}
|
||||
|
||||
// We'll also create a REST proxy that'll convert any REST calls to gRPC
|
||||
// calls and forward them to the internal listener.
|
||||
if g.cfg.EnableREST {
|
||||
if err := g.createRESTProxy(); err != nil {
|
||||
return fmt.Errorf("error creating REST proxy: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the instances of our subservers now so we can hook them up to
|
||||
// lnd once it's fully started.
|
||||
bufRpcListener := bufconn.Listen(100)
|
||||
g.faradayServer = frdrpcserver.NewRPCServer(g.cfg.faradayRpcConfig)
|
||||
g.loopServer = loopd.New(g.cfg.Loop, nil)
|
||||
g.poolServer = pool.NewServer(g.cfg.Pool)
|
||||
g.rpcProxy = newRpcProxy(
|
||||
g.cfg, g, g.validateSuperMacaroon, g.permsMgr,
|
||||
)
|
||||
g.accountService, err = accounts.NewService(
|
||||
filepath.Dir(g.cfg.MacaroonPath), g.errQueue.ChanIn(),
|
||||
)
|
||||
|
|
@ -345,12 +361,14 @@ func (g *LightningTerminal) Run() error {
|
|||
|
||||
// Call the "real" main in a nested manner so the defers will properly
|
||||
// be executed in the case of a graceful shutdown.
|
||||
readyChan := make(chan struct{})
|
||||
bufReadyChan := make(chan struct{})
|
||||
unlockChan := make(chan struct{})
|
||||
lndQuit := make(chan struct{})
|
||||
macChan := make(chan []byte, 1)
|
||||
|
||||
var (
|
||||
bufRpcListener = bufconn.Listen(100)
|
||||
readyChan = make(chan struct{})
|
||||
bufReadyChan = make(chan struct{})
|
||||
unlockChan = make(chan struct{})
|
||||
lndQuit = make(chan struct{})
|
||||
macChan = make(chan []byte, 1)
|
||||
)
|
||||
if g.cfg.LndMode == ModeIntegrated {
|
||||
lisCfg := lnd.ListenerCfg{
|
||||
RPCListeners: []*lnd.ListenerWithSignal{{
|
||||
|
|
@ -399,14 +417,6 @@ func (g *LightningTerminal) Run() error {
|
|||
_ = g.RegisterGrpcSubserver(g.rpcProxy.grpcServer)
|
||||
}
|
||||
|
||||
// We'll also create a REST proxy that'll convert any REST calls to gRPC
|
||||
// calls and forward them to the internal listener.
|
||||
if g.cfg.EnableREST {
|
||||
if err := g.createRESTProxy(); err != nil {
|
||||
return fmt.Errorf("error creating REST proxy: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for lnd to be started up so we know we have a TLS cert.
|
||||
select {
|
||||
// If lnd needs to be unlocked we get the signal that it's ready to do
|
||||
|
|
@ -444,16 +454,11 @@ func (g *LightningTerminal) Run() error {
|
|||
}
|
||||
|
||||
// Now start the RPC proxy that will handle all incoming gRPC, grpc-web
|
||||
// and REST requests. We also start the main web server that dispatches
|
||||
// requests either to the static UI file server or the RPC proxy. This
|
||||
// makes it possible to unlock lnd through the UI.
|
||||
// and REST requests.
|
||||
if err := g.rpcProxy.Start(g.lndConn); err != nil {
|
||||
return fmt.Errorf("error starting lnd gRPC proxy server: %v",
|
||||
err)
|
||||
}
|
||||
if err := g.startMainWebServer(); err != nil {
|
||||
return fmt.Errorf("error starting UI HTTP server: %v", err)
|
||||
}
|
||||
|
||||
// Now that we have started the main UI web server, show some useful
|
||||
// information to the user so they can access the web UI easily.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue