Skip to content

Commit

Permalink
update version 0.2 - support taskID or name
Browse files Browse the repository at this point in the history
  • Loading branch information
gondor committed May 5, 2016
1 parent e916e75 commit 3c271eb
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 33 deletions.
23 changes: 23 additions & 0 deletions .goxc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"ArtifactsDest": "build",
"ConfigVersion": "0.9",
"PackageVersion": "0.1",
"TaskSettings": {
"bintray": {
"user": "gondor",
"package": "go-mesoslog",
"repository": "utils",
"subject": "containx"
},
"publish-github": {
"owner": "ContainX",
"repository": "go-mesoslog"
},
"debs": {
"metadata": {
"description": "Go-Mesoslog - Print and Tail Mesos logs",
"maintainer": "Jeremy Unruh (https://github.com/gondor)"
}
}
}
}
32 changes: 21 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
VERSION = 0.1
VERSION = 0.2

GO_FMT = gofmt -w
GO_XC = goxc -os="linux darwin windows freebsd openbsd"
GO_FMT = gofmt -s -w -l .
GO_XC = goxc -os="linux darwin windows" -tasks-="rmbin"

GOXC_FILE = .goxc.local.json

all: deps
all: deps compile

compile: goxc

goxc:
$(shell echo '{\n "ArtifactsDest": "build",\n "ConfigVersion": "0.9",' > $(GOXC_FILE))
$(shell echo ' "PackageVersion": "$(VERSION)",\n "TaskSettings": {' >> $(GOXC_FILE))
$(shell echo ' "bintray": {\n "user": "gondor",\n "apikey": "$BINTRAY_APIKEY",\n "package": "go-mesoslog",' >> $(GOXC_FILE))
$(shell echo ' "repository": "utils",\n "subject": "pacesys"' >> $(GOXC_FILE))
$(shell echo ' }\n }\n}' >> $(GOXC_FILE))
$(GO_XC)
$(shell echo '{\n "ConfigVersion": "0.9",\n "PackageVersion": "$(VERSION)",' > $(GOXC_FILE))
$(shell echo ' "TaskSettings": {' >> $(GOXC_FILE))
$(shell echo ' "bintray": {\n "apikey": "$(BINTRAY_APIKEY)"' >> $(GOXC_FILE))
$(shell echo ' },' >> $(GOXC_FILE))
$(shell echo ' "publish-github": {' >> $(GOXC_FILE))
$(shell echo ' "apikey": "$(GITHUB_APIKEY)",' >> $(GOXC_FILE))
$(shell echo ' "body": "",' >> $(GOXC_FILE))
$(shell echo ' "include": "*.zip,*.tar.gz,*.deb,go-mesoslog_$(VERSION)_linux_amd64-bin"' >> $(GOXC_FILE))
$(shell echo ' }\n } \n}' >> $(GOXC_FILE))
$(GO_XC)

deps:
go get

format:
$(GO_FMT)

bintray:
$(GO_XC) bintray
$(GO_XC) bintray

github:
$(GO_XC) publish-github
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,21 @@ Global Flags
-m, --master : - Mesos Master host:port (eg. 192.168.2.1:5050)
```

### Binary Installation
### Binary Installation

You can download the binaries (ver 0.1)

* Architecture i386 [ [linux](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_linux_386.tar.gz?direct) / [windows](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_windows_386.zip?direct) / [darwin](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_darwin_386.zip?direct) / [freebsd](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_freebsd_386.zip?direct) / [openbsd](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_openbsd_386.zip?direct) ]
* Architecture amd64 [ [linux](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_linux_amd64.tar.gz?direct) / [windows](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_windows_amd64.zip?direct) / [darwin](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_darwin_amd64.zip?direct) / [freebsd](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_freebsd_amd64.zip?direct) / [openbsd](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_openbsd_amd64.zip?direct) ]

Or by installing via deb packages (ver 0.1)

* [ [amd64](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_amd64.deb?direct) / [armhf](https://dl.bintray.com//content/pacesys/utils/go-mesoslog_0.1_armhf.deb?direct) ]
Binaries are available through GitHub releases. You can download the appropriate binary, package and version from the [Releases](https://github.com/ContainX/go-mesoslog/releases) page

### Build and Install the Binaries from Source

Add Go-Mesoslog and its package dependencies to your go `src` directory

go get -v github.com/gondor/go-mesoslog
go get -v github.com/ContainX/go-mesoslog

Once the `get` has completed, you should find your new `go-mesoslog` (or `go-mesoslog.exe`) executable sitting inside the `$GOPATH/bin/`

To update Go-Mesoslog's dependencies, use `go get` with the `-u` option.

go get -u -v github.com/gondor/go-mesoslog
go get -u -v github.com/ContainX/go-mesoslog

## Why Go-Mesoslog

Expand All @@ -52,13 +45,13 @@ I wrote this quickly in one night to solve a few use cases. Feel free to fork a

## Looking for Mesos/Marathon, Kubernetes or ECS deployment in one tool?

Checkout [depcon](https://github.com/gondor/depcon)
Checkout [depcon](https://github.com/ContainX/depcon)

## License

This software is licensed under the Apache 2 license, quoted below.

Copyright 2015 Jeremy Unruh
Copyright 2016 ContainX / Jeremy Unruh

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
Expand Down
10 changes: 5 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main
// where the stdout and stderr streams for a running task can be viewed

import (
"bytes"
"encoding/json"
"fmt"
"io"
Expand All @@ -13,14 +14,13 @@ import (
"os"
"path/filepath"
"strings"
"time"
"sync"
"bytes"
"time"
)

const (
// PageLength is the amount of data we want to consume during log tailing
PageLength int = 5000
PageLength int = 5000
TailURIFmt string = "http://%s:5051/files/read.json?path=%s&offset=%v&length=%v"
)

Expand Down Expand Up @@ -118,7 +118,7 @@ func (c *MesosClient) TailLog(appID string, logtype LogType, duration int) error
return nil
}

func (c *MesosClient) asyncTail(task *mstateTask, s *slaveInfo, lt LogType, duration int) <- chan string{
func (c *MesosClient) asyncTail(task *mstateTask, s *slaveInfo, lt LogType, duration int) <-chan string {
ch := make(chan string)
path := fmt.Sprintf("%s/%s", s.Directory, lt.String())
go func() {
Expand Down Expand Up @@ -250,7 +250,7 @@ func findTask(state *masterState, appID string) map[string]*mstateTask {
m := make(map[string]*mstateTask)
for _, framework := range state.Frameworks {
for _, task := range framework.Tasks {
if task.Name == appID {
if task.Name == appID || task.ID == appID {
m[task.ID] = task
}
}
Expand Down
4 changes: 2 additions & 2 deletions mesoslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,15 @@ func getLogType() LogType {
func client() *MesosClient {
var host string
var port = 5050
master, err := rootCmd.PersistentFlags().GetString(MasterFlag);
master, err := rootCmd.PersistentFlags().GetString(MasterFlag)

if master == "" {
if os.Getenv(EnvMesosMaster) == "" {
printErr(fmt.Errorf("Must define a Master host and optional port"))
os.Exit(1)
}
master = os.Getenv(EnvMesosMaster)
// master = "internal-lt-mesos-privatee-mw3lkjkwdyni-213084364.us-west-2.elb.amazonaws.com:5050"
}

if strings.Contains(master, ":") {
Expand All @@ -158,7 +159,6 @@ func client() *MesosClient {
host = master
}


c, err := NewMesosClient(host, port)
if err != nil {
printErr(err)
Expand Down
4 changes: 2 additions & 2 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type slaveInfo struct {
}

type readData struct {
Data string `json:"data"`
Offset int `json:"offset"`
Data string `json:"data"`
Offset int `json:"offset"`
}

// LogOut - struct which holds the result from getting Mesos logs
Expand Down

0 comments on commit 3c271eb

Please sign in to comment.