Skip to content

Commit

Permalink
Use web.go instead of dist.go
Browse files Browse the repository at this point in the history
  • Loading branch information
syifan committed May 31, 2023
1 parent ee36faf commit 4473c8c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 3 additions & 4 deletions monitoring/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import (
// Enable profiling
_ "net/http/pprof"

"github.com/sarchlab/akita/v3/sim"

"github.com/google/pprof/profile"
"github.com/gorilla/mux"
"github.com/sarchlab/akita/v3/monitoring/web/dist"
"github.com/sarchlab/akita/v3/monitoring/web"
"github.com/sarchlab/akita/v3/sim"
"github.com/shirou/gopsutil/process"
"github.com/syifan/goseth"
)
Expand Down Expand Up @@ -134,7 +133,7 @@ func (m *Monitor) CompleteProgressBar(pb *ProgressBar) {
func (m *Monitor) StartServer() {
r := mux.NewRouter()

fs := dist.GetAssets()
fs := web.GetAssets()
fServer := http.FileServer(fs)
r.HandleFunc("/api/pause", m.pauseEngine)
r.HandleFunc("/api/continue", m.continueEngine)
Expand Down
16 changes: 11 additions & 5 deletions monitoring/web/dist/dist.go → monitoring/web/web.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Package dist includes the static web pages for the monitoring tool.
package dist
// Package web includes the static web pages for the monitoring tool.
package web

import (
"embed"
"fmt"
"io/fs"
"net/http"
"os"
"path"
"runtime"
"strings"
)

//go:embed index.html assets/*
//go:embed dist/*
var staticAssets embed.FS

// GetAssets returns the static assets
Expand All @@ -22,7 +23,7 @@ func GetAssets() http.FileSystem {
panic("error getting path")
}

assetPath = path.Join(path.Dir(assetPath), "/web")
assetPath = path.Join(path.Dir(assetPath), "/dist")

// path := path.Join(path.Dir(filename), "../config/settings.toml")

Expand All @@ -31,7 +32,12 @@ func GetAssets() http.FileSystem {
return http.Dir(assetPath)
}

return http.FS(staticAssets)
subFS, err := fs.Sub(staticAssets, "/dist")
if err != nil {
panic(err)
}

return http.FS(subFS)
}

// isDevelopmentMode returns true if environment variable AKITA_MONITOR_DEV is
Expand Down

0 comments on commit 4473c8c

Please sign in to comment.