Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced WebUI #4406

Merged
merged 16 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
yarn-error.log
lib
!pkg/lib
!webui/lib
.DS_Store
dist/*.sha256
dist/*.tar.gz
Expand Down
23 changes: 8 additions & 15 deletions cmd/cli/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net"
"net/url"
"os"
"strconv"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -193,24 +192,18 @@ func serve(cmd *cobra.Command, cfg types.Bacalhau, fsRepo *repo.FsRepo) error {

// Start up Dashboard - default: 8483
if cfg.WebUI.Enabled {
apiURL := standardNode.APIServer.GetURI().JoinPath("api", "v1")
host, portStr, err := net.SplitHostPort(cfg.WebUI.Listen)
if err != nil {
return err
webuiConfig := webui.Config{
APIEndpoint: standardNode.APIServer.GetURI().String(),
Listen: cfg.WebUI.Listen,
}
webuiPort, err := strconv.ParseInt(portStr, 10, 64)
webuiServer, err := webui.NewServer(webuiConfig)
if err != nil {
return err
// not failing the node if the webui server fails to start
log.Error().Err(err).Msg("Failed to start ui server")
}
go func() {
// Specifically leave the host blank. The app will just use whatever
// host it is served on and replace the port and path.
apiPort := apiURL.Port()
apiPath := apiURL.Path

err := webui.ListenAndServe(ctx, host, apiPort, apiPath, int(webuiPort))
if err != nil {
cmd.PrintErrln(err)
if err := webuiServer.ListenAndServe(ctx); err != nil {
log.Error().Err(err).Msg("ui server error")
}
}()
}
Expand Down
Loading
Loading