Skip to content

Commit

Permalink
Merge 2bb5afc into 527cde4
Browse files Browse the repository at this point in the history
  • Loading branch information
badiib committed Apr 7, 2017
2 parents 527cde4 + 2bb5afc commit 9342c15
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -12,5 +12,6 @@ _site/
env/
Gemfile.lock
vendor/
examples/hotrod/hotrod
jaeger-ui-build/
examples/hotrod/hotrod*
cmd/standalone/standalone*
24 changes: 24 additions & 0 deletions .travis.yml
Expand Up @@ -8,10 +8,34 @@ go:
services:
- docker

env:
global:
- COMMIT=${TRAVIS_COMMIT::8}
# DOCKER_USER
- secure: TNvbr5/d7raSovEtttxdrZl8tP7vCCzL56gKKhr2wF4ET5/iRbcfSP9zoFPEOlIdgmCHZhGTh+fED1Eqgyswv6HPOAfEuov5vtzNB9fkcI46/nRk7KbiDlcEuE2IFtwkijFDz6YdJlbPCozHa81/Ih6G20H61tgv6f0AsGGT9MR7DQ71cCu8xZykNDjEKTo7RF6GiqG2VYa+S1P3vCOKRv31ouo/a5SPP+1AIvAg8u++qWVC8WJixmkXnw2OplvCFgHS0dlT3FvUPjYtUtLens5gpBDo7kn7+Ba27m2D0IzkzDPW5sK0YMMZW61LLn8GLPiJtLqzUHovaJ2NcFfi07RQ4GSMnwnjP0nLQbgd0CzM2zJGJRcOTkYe7IEDrdcTBcljZdZAJdoJEzrGYYWRQcX0Kyjc83ghX3A5s+CQWlPElQrkBB7KhNZ+w2Cn4+Mr6zOiRnBYg1NIUV2eGHMNnC4HI9RqgvA1QqcT5YHWqpz20sddHx1kgzgh8vOW8csiFon/Wrvyb2TaemzsKxIlT/UZZfDuyWG/Lvm4oxmTp1GrgQsC2iJjox4z6VIxbhykZEqNU1dhY6KuvgjEGetxk2j/NVfI8Qb4tvWqKoXq5Buap/J0AWjxWjGbrIGZbz5FgzfEP33WR8X2Oh5Cy+TMl1v0+YBAB3OaMpe/Qe2rGlk= # DOCKER_PASS
# DOCKER_PASS
- secure: mX3/Gwv5esCjU9GfqDaXbTslA0UOY9q45+rnW58X6z1tY2pFOts5uhtLve3YneGn3IN0n+m5mcljim72vKNQaPJCSodYfcfrqth2YqkYTXNWykOIdlLs1u58pYYGRXJaAlD4EgQysB/nAaQYO00/n2tBq4vEmu0dikbJer97smStkokLBiz42tJbvY6mikqnHHbRAA4dw5MHwYikDkI82oKxUsB8horetMmXgwTkT3AiE5UufXm3iYxpZ48KTYBW8WbQSQV1T1nriisZVErbYh69QLaLrEK3/WYiN3r4fOag4JvMA5GuPpuVGQfKzXUuFptG54VBbPKCgmcXA/DlaEQ6HILsfHdl29/AXHa59dVjWGfQ5f/N4VWaIVXhE0qWo+/WIoyr7SaLybyGVe3gf1vDaDFlfVlrE7j13H+XKiwzfOeaqnTrcNc/MSCFCtnUbjvX4UlXCbE4gVbCuEsjAPQ8mI/MMaCWLxhaYTW/cSyGRTGMLwe4Q8uAPd3BQat63byLo3BfK+icyw24RbSGBDRu5FZORK164MMjr0+UKVT3gh5/JdFxLkdOGjJL/9QuppNShI5GBIctIg15AQJNkhSLm8DxUTNHhjjBgXzqNhDVmUQLQVgqCWlHh1HVF5eiIQXBNGBE1Lw9v9dGTUHlPUUqeJKsxEyYWfZuY4tNhzU=

install:
- nvm version
- node -v
- make install_ci

script:
- make test_ci
- travis_retry goveralls -coverprofile=cover.out -service=travis-ci || true

after_success:
- git clone https://github.com/uber/jaeger-ui
- cd jaeger-ui && npm install && npm run build && cd ..
- mkdir jaeger-ui-build && cp -r jaeger-ui/build jaeger-ui-build/
- make build_standalone_linux
- export REPO=jaegertracing/all-in-one
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- export TAG=`if [ "$BRANCH" == "master" ]; then echo "latest"; else echo $BRANCH; fi`
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, REPO=$REPO, PR=$PR, BRANCH=$BRANCH, TAG=$TAG"
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- docker build -f cmd/standalone/Dockerfile -t $REPO:$COMMIT .
# - docker tag $REPO:$COMMIT $REPO:$TAG TODO docker doesn't like tags with \ need to omit them
- docker tag $REPO:$COMMIT $REPO:travis-$TRAVIS_BUILD_NUMBER
- docker push $REPO
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -82,6 +82,12 @@ install_examples: install
build_examples:
go build -o ./examples/hotrod/hotrod-demo ./examples/hotrod/main.go

build_standalone:
go build -o ./cmd/standalone/standalone ./cmd/standalone/main.go

build_standalone_linux:
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./cmd/standalone/standalone-linux ./cmd/standalone/main.go

.PHONY: cover
cover:
./scripts/cover.sh $(shell go list $(PACKAGES))
Expand Down
2 changes: 2 additions & 0 deletions cmd/query/app/builder/builder_flags.go
Expand Up @@ -27,4 +27,6 @@ var (
QueryPort = flag.Int("query.port", 16686, "The port for the query service")
// QueryPrefix is the prefix of the query service api
QueryPrefix = flag.String("query.prefix", "api", "The prefix for the url of the query service")
// QueryStaticAssets is the path for the static assets for the UI (https://github.com/uber/jaeger-ui)
QueryStaticAssets = flag.String("query.static-files", "jaeger-ui-build/build/", "The path for the static assets for the UI")
)
5 changes: 5 additions & 0 deletions cmd/query/app/fixture/index.html
@@ -0,0 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Test Page</title>
</html>
23 changes: 14 additions & 9 deletions cmd/query/app/static_handler.go
Expand Up @@ -27,35 +27,40 @@ import (
)

const (
staticAssetsRoot = "jaeger-ui-build/build/"
defaultStaticAssetsRoot = "jaeger-ui-build/build/"
)

var (
staticRootFiles = []string{"favicon.ico"}
)

// StaticAssetsHandler handles static assets
type StaticAssetsHandler struct{}
type StaticAssetsHandler struct {
staticAssetsRoot string
}

// NewStaticAssetsHandler returns a StaticAssetsHandler
func NewStaticAssetsHandler() *StaticAssetsHandler {
return &StaticAssetsHandler{}
func NewStaticAssetsHandler(staticAssetsRoot string) *StaticAssetsHandler {
if staticAssetsRoot == "" {
staticAssetsRoot = defaultStaticAssetsRoot
}
return &StaticAssetsHandler{staticAssetsRoot: staticAssetsRoot}
}

// RegisterRoutes registers routes for this handler on the given router
func (sH *StaticAssetsHandler) RegisterRoutes(router *mux.Router) {
router.PathPrefix("/static").Handler(http.FileServer(http.Dir(staticAssetsRoot)))
router.PathPrefix("/static").Handler(http.FileServer(http.Dir(sH.staticAssetsRoot)))
for _, file := range staticRootFiles {
router.Path("/" + file).HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, staticAssetsRoot+file)
http.ServeFile(w, r, sH.staticAssetsRoot+file)
})
}
router.NotFoundHandler = http.HandlerFunc(notFound)
router.NotFoundHandler = http.HandlerFunc(sH.notFound)
}

func notFound(w http.ResponseWriter, r *http.Request) {
func (sH *StaticAssetsHandler) notFound(w http.ResponseWriter, r *http.Request) {
// don't allow returning "304 Not Modified" for index.html because
// the cached versions might have the wrong filenames for javascript assets
delete(r.Header, "If-Modified-Since")
http.ServeFile(w, r, staticAssetsRoot+"index.html")
http.ServeFile(w, r, sH.staticAssetsRoot+"index.html")
}
4 changes: 2 additions & 2 deletions cmd/query/app/static_handler_test.go
Expand Up @@ -32,7 +32,7 @@ import (

func TestStaticAssetsHandler(t *testing.T) {
r := mux.NewRouter()
handler := NewStaticAssetsHandler()
handler := NewStaticAssetsHandler("fixture/")
handler.RegisterRoutes(r)
server := httptest.NewServer(r)
defer server.Close()
Expand All @@ -44,5 +44,5 @@ func TestStaticAssetsHandler(t *testing.T) {
resp, err := httpClient.Get(server.URL)
assert.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusNotFound, resp.StatusCode)
assert.Equal(t, http.StatusOK, resp.StatusCode)
}
2 changes: 1 addition & 1 deletion cmd/query/main.go
Expand Up @@ -68,7 +68,7 @@ func main() {
app.HandlerOptions.Adjusters(app.StandardAdjusters),
app.HandlerOptions.Prefix(*builder.QueryPrefix),
app.HandlerOptions.Logger(logger))
sHandler := app.NewStaticAssetsHandler()
sHandler := app.NewStaticAssetsHandler(*builder.QueryStaticAssets)
r := mux.NewRouter()
rHandler.RegisterRoutes(r)
sHandler.RegisterRoutes(r)
Expand Down
10 changes: 10 additions & 0 deletions cmd/standalone/Dockerfile
@@ -0,0 +1,10 @@
FROM golang:1.7
EXPOSE 5775 6831 6832 14267 16686

COPY ./jaeger-ui-build /go/src/jaeger-ui-build
COPY ./cmd/standalone/standalone-linux /go/bin/

ENTRYPOINT /go/bin/standalone-linux --span-storage.type=memory --query.static-files=/go/src/jaeger-ui-build/build/

#example build command from github.com/uber/jaeger directory: docker build -f cmd/standalone/Dockerfile -t standalone .
#example docker run command: docker run --net=host --publish 5755:5775 --publish 6831:6832 --publish 14267:14267 --publish 16686:16686 --name standalone --rm standalone
2 changes: 1 addition & 1 deletion cmd/standalone/main.go
Expand Up @@ -139,7 +139,7 @@ func startQuery(logger *zap.Logger, baseFactory metrics.Factory, memoryStore *me
dependencyReader,
queryApp.HandlerOptions.Prefix(*query.QueryPrefix),
queryApp.HandlerOptions.Logger(logger))
sHandler := queryApp.NewStaticAssetsHandler()
sHandler := queryApp.NewStaticAssetsHandler(*query.QueryStaticAssets)
r := mux.NewRouter()
rHandler.RegisterRoutes(r)
sHandler.RegisterRoutes(r)
Expand Down

0 comments on commit 9342c15

Please sign in to comment.