From 20cf5ba54c24c7867acb6305fd4399a6ea26aa17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 11 Oct 2019 08:11:57 +0200 Subject: [PATCH] townhall: Single-binary build --- .gitignore | 1 + Makefile | 7 +++++++ cmd/lotus-townhall/main.go | 4 +++- cmd/lotus-townhall/townhall/src/App.js | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4e008cccc..9b0a66bcd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /lotus /lotus-storage-miner /pond +/townhall /lotuspond/front/node_modules /lotuspond/front/build **/*.h diff --git a/Makefile b/Makefile index ce08f30ef..441bc03fc 100644 --- a/Makefile +++ b/Makefile @@ -88,6 +88,13 @@ pond: build (cd lotuspond/front && npm i && npm run build) .PHONY: pond +townhall: + rm -f townhall + go build -o townhall ./cmd/lotus-townhall + (cd ./cmd/lotus-townhall/townhall && npm i && npm run build) + go run github.com/GeertJohan/go.rice/rice append --exec townhall -i ./cmd/lotus-townhall +.PHONY: townhall + clean: rm -rf $(CLEAN) -$(MAKE) -C $(BLS_PATH) clean diff --git a/cmd/lotus-townhall/main.go b/cmd/lotus-townhall/main.go index 64b7f423c..b7534d046 100644 --- a/cmd/lotus-townhall/main.go +++ b/cmd/lotus-townhall/main.go @@ -7,6 +7,7 @@ import ( "net/http" "strings" + rice "github.com/GeertJohan/go.rice" "github.com/gorilla/websocket" "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p-core/peer" @@ -59,8 +60,9 @@ func main() { } http.HandleFunc("/sub", handler(ps)) + http.Handle("/", http.FileServer(rice.MustFindBox("townhall/build").HTTPBox())) - fmt.Println("listening") + fmt.Println("listening on http://localhost:2975") if err := http.ListenAndServe("0.0.0.0:2975", nil); err != nil { panic(err) diff --git a/cmd/lotus-townhall/townhall/src/App.js b/cmd/lotus-townhall/townhall/src/App.js index 426588d60..5b5ca5bca 100644 --- a/cmd/lotus-townhall/townhall/src/App.js +++ b/cmd/lotus-townhall/townhall/src/App.js @@ -5,8 +5,8 @@ class App extends React.Component { constructor(props) { super(props); - //let ws = new WebSocket("ws://" + window.location.host + "/sub") - let ws = new WebSocket("ws://127.0.0.1:2975/sub") + let ws = new WebSocket("ws://" + window.location.host + "/sub") + //let ws = new WebSocket("ws://127.0.0.1:2975/sub") ws.onmessage = (ev) => { console.log(ev)