summaryrefslogtreecommitdiff
path: root/src/hub
diff options
context:
space:
mode:
authorMarkus Grüneis <gimpf@gimpf.org>2014-10-23 13:24:04 +0200
committerMarkus Grüneis <gimpf@gimpf.org>2014-10-23 13:24:04 +0200
commit4717ba0aae3d2cb7fed370ee55fc6e6841def315 (patch)
treea208fb507ea3055ff0925b88830a517ed363fa98 /src/hub
parenthub: fix filtered queries, remove unused functions (diff)
hub: serve viz app under /viz
Diffstat (limited to 'src/hub')
-rw-r--r--src/hub/src/spreadspace.org/sfive-hub/s5hub.go3
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvWeb.go13
-rwxr-xr-xsrc/hub/test-srv2
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"