mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Open Web UI in Browser Automatically (#7481)
* open web * Update shared/browser/browser_test.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * Update shared/browser/browser.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * add to depz.bazel * run gazelle Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,7 @@ go_library(
|
||||
visibility = ["//validator:__subpackages__"],
|
||||
deps = [
|
||||
"//shared:go_default_library",
|
||||
"//shared/browser:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const prefix = "external/prysm_web_ui"
|
||||
|
||||
@@ -6,10 +6,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/prysmaticlabs/prysm/shared/browser"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var _ = shared.Service(&Server{})
|
||||
var (
|
||||
_ = shared.Service(&Server{})
|
||||
log = logrus.WithField("prefix", "prysm-web")
|
||||
)
|
||||
|
||||
// Server for the Prysm Web UI.
|
||||
type Server struct {
|
||||
@@ -37,6 +41,16 @@ func (s *Server) Start() {
|
||||
log.WithError(err).Error("Failed to start validator web server")
|
||||
}
|
||||
}()
|
||||
time.Sleep(time.Second * 1)
|
||||
cmd, err := browser.Command("http://" + s.http.Addr)
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("Could not open Prysm web UI in browser")
|
||||
return
|
||||
}
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.WithError(err).Errorf("Could not open Prysm web UI in browser")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Stop the web server gracefully with 1s timeout.
|
||||
|
||||
Reference in New Issue
Block a user