diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive-hub/s5hub.go | 3 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srvWeb.go | 13 | ||||
-rwxr-xr-x | src/hub/test-srv | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go index 3f41fea..2509139 100644 --- a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go +++ b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go @@ -19,6 +19,7 @@ func main() { startGramPipe := flag.Bool("start-pipegram-server", true, "start a datagram oriented pipe server; see option pipegram") startWeb := flag.Bool("start-web-server", true, "start a webserver") forward := flag.String("forward-url", "", "forward to another sfive-server with http server at base-url") + vizAppDir := flag.String("viz-dir", "./viz", "base-path to the viz application") flag.Parse() @@ -56,7 +57,7 @@ func main() { go func() { defer wg.Done() s5hl.Println("start web-srv") - server.ServeWeb() + server.ServeWeb(*vizAppDir) s5hl.Println("web finished") }() } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go index 7adbb81..31964ad 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "net/http" + "os" "strconv" "time" @@ -180,7 +181,15 @@ func (self StatsSinkServer) getStats(c web.C, w http.ResponseWriter, r *http.Req fmt.Fprintf(w, "%s", jsonString) } -func (self StatsSinkServer) ServeWeb() { +func (self StatsSinkServer) ServeWeb(vizAppLocation string) { + if _, err := os.Stat(vizAppLocation); err != nil { + if os.IsNotExist(err) { + s5l.Panicf("web: viz-app at %s does not exist.", vizAppLocation) + } else { + s5l.Printf("web: failed to stat %s: %v", vizAppLocation, err) + } + } + goji.Get("/hello/:name", hello) goji.Get("/tags", self.getTagList) goji.Get("/sources", self.getSourcesList) @@ -189,5 +198,7 @@ func (self StatsSinkServer) ServeWeb() { goji.Get("/updates/:id", self.getUpdate) goji.Post("/updates", self.postUpdate) goji.Get("/stats", self.getStats) + goji.Handle("/viz/*", http.StripPrefix("/viz/", http.FileServer(http.Dir(vizAppLocation)))) + goji.Serve() } diff --git a/src/hub/test-srv b/src/hub/test-srv index 8240868..f21c879 100755 --- a/src/hub/test-srv +++ b/src/hub/test-srv @@ -1,4 +1,4 @@ #!/bin/sh rm -f /run/sfive/pipe /run/sfive/pipegram -./bin/sfive-hub -db /var/lib/sfive/db.sqlite -start-pipe-server -pipe /var/run/sfive/pipe -start-web-server +./bin/sfive-hub -db /var/lib/sfive/db.sqlite -start-pipe-server -pipe /var/run/sfive/pipe -start-web-server -viz-dir "$(pwd)/../viz" |