Skip to content

Commit

Permalink
Merge pull request #5 from mattn/monitor-addr
Browse files Browse the repository at this point in the history
Possible to change address of monitor
  • Loading branch information
ngaut committed Jul 10, 2014
2 parents e8a7a80 + 063f3e2 commit 3add67d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ how to query job status ?
how to list all jobs ?

http://localhost:3000/job

how to change monitor address ?

export GEARMAND_MONITOR_ADDR=:4567

## TODO:
refactor storage and tests
Expand Down
13 changes: 12 additions & 1 deletion server/restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package server

import (
"github.com/go-martini/martini"
log "github.com/ngaut/logging"
"github.com/ngaut/stats"
"net/http"
"net/http/pprof"
_ "net/http/pprof"
"os"
)

func getJob(s *Server, params martini.Params) string {
Expand All @@ -26,6 +29,14 @@ func getWorker(s *Server, params martini.Params) string {
}

func registerWebHandler(s *Server) {
addr := os.Getenv("GEARMAND_MONITOR_ADDR")
if addr == "" {
addr = ":3000"
} else if addr == "-" {
// Don't start web monitor
return
}

m := martini.Classic()

m.Get("/debug/pprof", pprof.Index)
Expand Down Expand Up @@ -56,5 +67,5 @@ func registerWebHandler(s *Server) {
return getWorker(s, params)
})

m.Run()
log.Fatal(http.ListenAndServe(addr, m))
}

0 comments on commit 3add67d

Please sign in to comment.