Skip to content

Commit

Permalink
Merge pull request #11573 from filecoin-project/debugWeb
Browse files Browse the repository at this point in the history
Debug Web 2: rearrange
  • Loading branch information
magik6k authored Jan 15, 2024
2 parents 512c70b + 32559aa commit 5091434
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 19 deletions.
5 changes: 2 additions & 3 deletions cmd/lotus-provider/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/cmd/lotus-provider/web"
"github.com/filecoin-project/lotus/lib/rpcenc"
"github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/metrics/proxy"
"github.com/filecoin-project/lotus/provider/lpweb"
"github.com/filecoin-project/lotus/storage/paths"
)

Expand Down Expand Up @@ -79,7 +79,6 @@ func (p *ProviderAPI) Shutdown(context.Context) error {
}

func ListenAndServe(ctx context.Context, dependencies *deps.Deps, shutdownChan chan struct{}) error {

fh := &paths.FetchHandler{Local: dependencies.LocalStore, PfHandler: &paths.DefaultPartialFileHandler{}}
remoteHandler := func(w http.ResponseWriter, r *http.Request) {
if !auth.HasPerm(r.Context(), nil, api.PermAdmin) {
Expand Down Expand Up @@ -133,7 +132,7 @@ func ListenAndServe(ctx context.Context, dependencies *deps.Deps, shutdownChan c
eg.Go(srv.ListenAndServe)

if dependencies.Cfg.Subsystems.EnableWebGui {
web, err := web.GetSrv(ctx, dependencies)
web, err := lpweb.GetSrv(ctx, dependencies)
if err != nil {
return err
}
Expand Down
15 changes: 5 additions & 10 deletions cmd/lotus-provider/run.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package main

import (
"bytes"
"context"
"fmt"
"os"
"strings"
"time"

"github.com/BurntSushi/toml"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"go.opencensus.io/stats"
Expand All @@ -22,7 +20,6 @@ import (
"github.com/filecoin-project/lotus/lib/ulimit"
"github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/node/config"
)

type stackTracer interface {
Expand Down Expand Up @@ -174,13 +171,11 @@ var webCmd = &cli.Command{

webtxt, err := getConfig(db, "web")
if err != nil || webtxt == "" {
cfg := config.DefaultLotusProvider()
cfg.Subsystems.EnableWebGui = true
var b bytes.Buffer
if err = toml.NewEncoder(&b).Encode(cfg); err != nil {
return err
}
if err = setConfig(db, "web", b.String()); err != nil {

s := `[Susbystems]
EnableWebGui = true
`
if err = setConfig(db, "web", s); err != nil {
return err
}
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/gorilla/mux"

"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/cmd/lotus-provider/web/api/debug"
"github.com/filecoin-project/lotus/provider/lpweb/api/debug"
)

func Routes(r *mux.Router, deps *deps.Deps) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var templateDev = os.Getenv("LOTUS_WEB_DEV") == "1"
func (a *app) executeTemplate(w http.ResponseWriter, name string, data interface{}) {
if templateDev {
fs := os.DirFS("./cmd/lotus-provider/web/hapi/web")
a.t = template.Must(template.ParseFS(fs, "web/*"))
a.t = template.Must(template.ParseFS(fs, "*"))
}
if err := a.t.ExecuteTemplate(w, name, data); err != nil {
log.Errorf("execute template %s: %v", name, err)
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions cmd/lotus-provider/web/srv.go → provider/lpweb/srv.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package web defines the HTTP web server for static files and endpoints.
package web
// Package lpweb defines the HTTP web server for static files and endpoints.
package lpweb

import (
"context"
Expand All @@ -17,9 +17,9 @@ import (
"go.opencensus.io/tag"

"github.com/filecoin-project/lotus/cmd/lotus-provider/deps"
"github.com/filecoin-project/lotus/cmd/lotus-provider/web/api"
"github.com/filecoin-project/lotus/cmd/lotus-provider/web/hapi"
"github.com/filecoin-project/lotus/metrics"
"github.com/filecoin-project/lotus/provider/lpweb/api"
"github.com/filecoin-project/lotus/provider/lpweb/hapi"
)

//go:embed static
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 5091434

Please sign in to comment.