Review feedback

This commit is contained in:
Tom Wilkie
2015-12-09 12:45:13 +00:00
parent c749f5aa33
commit 949ae6f807
5 changed files with 17 additions and 24 deletions

2
.gitignore vendored
View File

@@ -51,4 +51,4 @@ experimental/_integration/_integration
*sublime-workspace
*npm-debug.log
app/static.go
prog/app/static.go
prog/static.go

View File

@@ -36,7 +36,7 @@ $(SCOPE_EXPORT): $(SCOPE_EXE) $(DOCKER_DISTRIB) docker/weave $(RUNSVINIT) docker
$(RUNSVINIT): vendor/runsvinit/*.go
$(SCOPE_EXE): $(shell find ./ -type f -name *.go) prog/app/static.go
$(SCOPE_EXE): $(shell find ./ -type f -name *.go) prog/static.go
ifeq ($(BUILD_IN_CONTAINER),true)
$(SCOPE_EXE) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE)
@@ -58,10 +58,10 @@ $(RUNSVINIT):
go build -ldflags "-extldflags \"-static\"" -o $@ ./$(@D)
endif
static: prog/app/static.go
static: prog/static.go
prog/app/static.go: client/build/app.js
esc -o $@ -prefix client/build -pkg app client/build
prog/static.go: client/build/app.js
esc -o $@ -prefix client/build client/build
ifeq ($(BUILD_IN_CONTAINER),true)
client/build/app.js: $(shell find client/app/scripts -type f) $(SCOPE_UI_BUILD_UPTODATE)
@@ -101,7 +101,7 @@ clean:
go clean ./...
$(SUDO) docker rmi $(SCOPE_UI_BUILD_IMAGE) $(SCOPE_BACKEND_BUILD_IMAGE) >/dev/null 2>&1 || true
rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \
$(SCOPE_EXE) $(RUNSVINIT) prog/app/static.go client/build/app.js docker/weave
$(SCOPE_EXE) $(RUNSVINIT) prog/static.go client/build/app.js docker/weave
ifeq ($(BUILD_IN_CONTAINER),true)
tests: $(SCOPE_BACKEND_BUILD_UPTODATE)

View File

@@ -1,4 +1,4 @@
package app
package main
import (
"flag"
@@ -6,13 +6,11 @@ import (
"log"
"math/rand"
"net/http"
_ "net/http/pprof"
"strconv"
"strings"
"time"
// a blank import should be only in a main or test package, or have a comment justifying it
_ "net/http/pprof"
"github.com/gorilla/mux"
"github.com/weaveworks/weave/common"
@@ -21,7 +19,7 @@ import (
)
// Router creates the mux for all the various app components.
func Router(c app.Collector) *mux.Router {
func router(c app.Collector) *mux.Router {
router := mux.NewRouter()
app.RegisterTopologyRoutes(c, router)
app.RegisterReportPostHandler(c, router)
@@ -31,7 +29,7 @@ func Router(c app.Collector) *mux.Router {
}
// Main runs the app
func Main() {
func appMain() {
var (
window = flag.Duration("window", 15*time.Second, "window")
listen = flag.String("http.address", ":"+strconv.Itoa(xfer.AppPort), "webserver listen address")
@@ -55,7 +53,7 @@ func Main() {
rand.Seed(time.Now().UnixNano())
app.UniqueID = strconv.FormatInt(rand.Int63(), 16)
log.Printf("app starting, version %s, ID %s", app.Version, app.UniqueID)
http.Handle("/", Router(app.NewCollector(*window)))
http.Handle("/", router(app.NewCollector(*window)))
go func() {
log.Printf("listening on %s", *listen)
log.Print(http.ListenAndServe(*listen, nil))

View File

@@ -3,13 +3,10 @@ package main
import (
"fmt"
"os"
"github.com/weaveworks/scope/prog/app"
"github.com/weaveworks/scope/prog/probe"
)
func usage() {
fmt.Printf("usage: %s (app|probe) args...\n", os.Args[0])
fmt.Fprintf(os.Stderr, "usage: %s (app|probe) args...\n", os.Args[0])
os.Exit(1)
}
@@ -23,9 +20,9 @@ func main() {
switch module {
case "app":
app.Main()
appMain()
case "probe":
probe.Main()
probeMain()
default:
usage()
}

View File

@@ -1,4 +1,4 @@
package probe
package main
import (
"flag"
@@ -7,14 +7,12 @@ import (
"math/rand"
"net"
"net/http"
_ "net/http/pprof"
"os"
"strconv"
"strings"
"time"
// a blank import should be only in a main or test package, or have a comment justifying it
_ "net/http/pprof"
"github.com/armon/go-metrics"
"github.com/weaveworks/weave/common"
@@ -34,7 +32,7 @@ import (
var version = "dev" // set at build time
// Main runs the probe
func Main() {
func probeMain() {
var (
targets = []string{fmt.Sprintf("localhost:%d", xfer.AppPort), fmt.Sprintf("scope.weave.local:%d", xfer.AppPort)}
token = flag.String("token", "default-token", "probe token")