Skip to content

Commit

Permalink
support for version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
martensson committed Feb 10, 2016
1 parent 010509f commit 309ccd0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .goxc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"Arch": "amd64",
"Os": "linux",
"PackageVersion": "0.2.0",
"PackageVersion": "0.2.1",
"TaskSettings": {
"deb": {
"armarch": "",
Expand Down
3 changes: 0 additions & 3 deletions marathon.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ type MarathonApps struct {
} `json:"apps"`
}

// Global http transport for connection reuse
var tr = &http.Transport{}

func eventStream() {
go func() {
client := &http.Client{
Expand Down
20 changes: 19 additions & 1 deletion nixy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"sync"

"github.com/BurntSushi/toml"
"github.com/gorilla/mux"
"github.com/peterbourgon/g2s"
"github.com/thoas/stats"
)
Expand All @@ -30,9 +32,13 @@ type Config struct {
Apps map[string]App
}

var VERSION string
var config Config
var statsd g2s.Statter

// Global http transport for connection reuse
var tr = &http.Transport{}

func nixy_reload(w http.ResponseWriter, r *http.Request) {
log.Println("Marathon reload triggered")
select {
Expand Down Expand Up @@ -76,9 +82,19 @@ func nixy_apps(w http.ResponseWriter, r *http.Request) {
return
}

func nixy_version(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "nixy "+VERSION)
return
}

func main() {
configtoml := flag.String("f", "nixy.toml", "Path to config. (default nixy.toml)")
version := flag.Bool("v", false, "prints current nixy version")
flag.Parse()
if *version {
fmt.Println(VERSION)
os.Exit(0)
}
file, err := ioutil.ReadFile(*configtoml)
if err != nil {
log.Fatal(err)
Expand All @@ -91,7 +107,9 @@ func main() {
statsd, _ = g2s.Dial("udp", config.Statsd)
}
nixystats := stats.New()
mux := http.NewServeMux()
//mux := http.NewServeMux()
mux := mux.NewRouter()
mux.HandleFunc("/", nixy_version)
mux.HandleFunc("/v1/reload", nixy_reload)
mux.HandleFunc("/v1/apps", nixy_apps)
mux.HandleFunc("/v1/health", nixy_health)
Expand Down

0 comments on commit 309ccd0

Please sign in to comment.