Skip to content

Commit d1fca14

Browse files
committed
multi: add support for building without UI
This commit adds support for building without UI. If the build tag "no_ui" is set the UI will be disabled.
1 parent ac23b2e commit d1fca14

File tree

4 files changed

+77
-48
lines changed

4 files changed

+77
-48
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,22 @@ go-build:
118118
$(GOBUILD) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litd-debug $(PKG)/cmd/litd
119119
$(GOBUILD) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litcli-debug $(PKG)/cmd/litcli
120120

121+
122+
go-build-noui:
123+
@$(call print, "Building lightning-terminal without UI.")
124+
$(GOBUILD) -tags="no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litd-debug $(PKG)/cmd/litd
125+
$(GOBUILD) -tags="no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" -o litcli-debug $(PKG)/cmd/litcli
126+
121127
go-install:
122128
@$(call print, "Installing lightning-terminal.")
123129
$(GOINSTALL) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litd
124130
$(GOINSTALL) -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litcli
125131

132+
go-install-noui:
133+
@$(call print, "Installing lightning-terminal without UI.")
134+
$(GOINSTALL) -tags="no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litd
135+
$(GOINSTALL) -tags="no_ui $(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" $(PKG)/cmd/litcli
136+
126137
go-install-cli:
127138
@$(call print, "Installing all CLI binaries.")
128139
$(GOINSTALL) -trimpath -tags="$(LND_RELEASE_TAGS)" -ldflags "$(LDFLAGS)" github.com/lightningnetwork/lnd/cmd/lncli

app.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//go:build !no_ui
2+
// +build !no_ui
3+
4+
package terminal
5+
6+
import (
7+
"embed"
8+
)
9+
10+
var (
11+
// appBuildFS is an in-memory file system that contains all the static
12+
// HTML/CSS/JS files of the UI. It is compiled into the binary with the
13+
// go 1.16 embed directive below. Because the path is relative to the
14+
// root package, all assets will have a path prefix of /app/build/ which
15+
// we'll strip by giving a sub directory to the HTTP server.
16+
//
17+
//go:embed app/build/*
18+
appBuildFS embed.FS
19+
)

app_noui.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build no_ui
2+
// +build no_ui
3+
4+
package terminal
5+
6+
import "embed"
7+
8+
var (
9+
appBuildFS embed.FS
10+
)

terminal.go

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package terminal
33
import (
44
"context"
55
"crypto/tls"
6-
"embed"
76
"encoding/hex"
87
"errors"
98
"fmt"
@@ -83,15 +82,6 @@ var (
8382
// set this to 200MiB atm.
8483
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(1 * 1024 * 1024 * 200)
8584

86-
// appBuildFS is an in-memory file system that contains all the static
87-
// HTML/CSS/JS files of the UI. It is compiled into the binary with the
88-
// go 1.16 embed directive below. Because the path is relative to the
89-
// root package, all assets will have a path prefix of /app/build/ which
90-
// we'll strip by giving a sub directory to the HTTP server.
91-
//
92-
//go:embed app/build/*
93-
appBuildFS embed.FS
94-
9585
// appFilesDir is the sub directory of the above build directory which
9686
// we pass to the HTTP server.
9787
appFilesDir = "app/build"
@@ -1159,44 +1149,43 @@ func (g *LightningTerminal) shutdown() error {
11591149
// between the embedded HTTP server and the RPC proxy. An incoming request will
11601150
// go through the following chain of components:
11611151
//
1162-
// Request on port 8443 <------------------------------------+
1163-
// | converted gRPC request |
1164-
// v |
1165-
// +---+----------------------+ other +----------------+ |
1166-
// | Main web HTTP server +------->+ Embedded HTTP | |
1167-
// +---+----------------------+____+ +----------------+ |
1168-
// | | |
1169-
// v any RPC or grpc-web call | any REST call |
1170-
// +---+----------------------+ |->+----------------+ |
1171-
// | grpc-web proxy | + grpc-gateway +-----------+
1172-
// +---+----------------------+ +----------------+
1173-
// |
1174-
// v native gRPC call with basic auth
1175-
// +---+----------------------+
1176-
// | interceptors |
1177-
// +---+----------------------+
1178-
// |
1179-
// v native gRPC call with macaroon
1180-
// +---+----------------------+
1181-
// | gRPC server |
1182-
// +---+----------------------+
1183-
// |
1184-
// v unknown authenticated call, gRPC server is just a wrapper
1185-
// +---+----------------------+
1186-
// | director |
1187-
// +---+----------------------+
1188-
// |
1189-
// v authenticated call
1190-
// +---+----------------------+ call to lnd or integrated daemon
1191-
// | lnd (remote or local) +---------------+
1192-
// | faraday remote | |
1193-
// | loop remote | +----------v----------+
1194-
// | pool remote | | lnd local subserver |
1195-
// +--------------------------+ | - faraday |
1196-
// | - loop |
1197-
// | - pool |
1198-
// +---------------------+
1199-
//
1152+
// Request on port 8443 <------------------------------------+
1153+
// | converted gRPC request |
1154+
// v |
1155+
// +---+----------------------+ other +----------------+ |
1156+
// | Main web HTTP server +------->+ Embedded HTTP | |
1157+
// +---+----------------------+____+ +----------------+ |
1158+
// | | |
1159+
// v any RPC or grpc-web call | any REST call |
1160+
// +---+----------------------+ |->+----------------+ |
1161+
// | grpc-web proxy | + grpc-gateway +-----------+
1162+
// +---+----------------------+ +----------------+
1163+
// |
1164+
// v native gRPC call with basic auth
1165+
// +---+----------------------+
1166+
// | interceptors |
1167+
// +---+----------------------+
1168+
// |
1169+
// v native gRPC call with macaroon
1170+
// +---+----------------------+
1171+
// | gRPC server |
1172+
// +---+----------------------+
1173+
// |
1174+
// v unknown authenticated call, gRPC server is just a wrapper
1175+
// +---+----------------------+
1176+
// | director |
1177+
// +---+----------------------+
1178+
// |
1179+
// v authenticated call
1180+
// +---+----------------------+ call to lnd or integrated daemon
1181+
// | lnd (remote or local) +---------------+
1182+
// | faraday remote | |
1183+
// | loop remote | +----------v----------+
1184+
// | pool remote | | lnd local subserver |
1185+
// +--------------------------+ | - faraday |
1186+
// | - loop |
1187+
// | - pool |
1188+
// +---------------------+
12001189
func (g *LightningTerminal) startMainWebServer() error {
12011190
// Initialize the in-memory file server from the content compiled by
12021191
// the go:embed directive. Since everything's relative to the root dir,

0 commit comments

Comments
 (0)