diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a2d022108..0081f4aa8 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -6,7 +6,7 @@ # http://code.google.com/legal/individual-cla-v1.0.html (electronic submission) # http://code.google.com/legal/corporate-cla-v1.0.html (requires FAX) # -# Note that the CLA isn't a copyright _assigment_ but rather a +# Note that the CLA isn't a copyright _assignment_ but rather a # copyright _license_. You retain the copyright on your # contributions. diff --git a/doc/environment-vars.txt b/doc/environment-vars.txt index e1b0c0d79..18e0dde2b 100644 --- a/doc/environment-vars.txt +++ b/doc/environment-vars.txt @@ -62,6 +62,9 @@ CAMLI_DEV_KEYBLOBS (string): CAMLI_HTTP_DEBUG (bool): Enable per-request logging in pkg/webserver. +CAMLI_HTTP_EXPVAR (bool): + Enable json export of expvars at /debug/vars + CAMLI_HTTP_PPROF (bool): Enable standard library's pprof handler at /debug/pprof/ diff --git a/make.go b/make.go index fc0561741..577f5d101 100644 --- a/make.go +++ b/make.go @@ -467,7 +467,7 @@ func verifyGoVersion() { version := fields[2] switch version { case "go1", "go1.0.1", "go1.0.2", "go1.0.3": - log.Fatalf("Your version of Go (%s) is too old. Camlistore requires Go 1.1 or later.") + log.Fatalf("Your version of Go (%s) is too old. Camlistore requires Go 1.1 or later.", version) } } diff --git a/pkg/serverconfig/serverconfig.go b/pkg/serverconfig/serverconfig.go index 119aaab05..506816c9b 100644 --- a/pkg/serverconfig/serverconfig.go +++ b/pkg/serverconfig/serverconfig.go @@ -22,6 +22,7 @@ package serverconfig import ( "encoding/json" "errors" + "expvar" "fmt" "io" "log" @@ -409,6 +410,9 @@ func (config *Config) InstallHandlers(hi HandlerInstaller, baseURL string, conte } hl.setupAll() + if v, _ := strconv.ParseBool(os.Getenv("CAMLI_HTTP_EXPVAR")); v { + hi.Handle("/debug/vars", expvarHandler{}) + } if v, _ := strconv.ParseBool(os.Getenv("CAMLI_HTTP_PPROF")); v { hi.Handle("/debug/pprof/", profileHandler{}) } @@ -426,6 +430,23 @@ func (s multiCloser) Close() (err error) { return } +// expvarHandler publishes expvar stats. +type expvarHandler struct{} + +func (expvarHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + fmt.Fprintf(w, "{\n") + first := true + expvar.Do(func(kv expvar.KeyValue) { + if !first { + fmt.Fprintf(w, ",\n") + } + first = false + fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) + }) + fmt.Fprintf(w, "\n}\n") +} + // profileHandler publishes server profile information. type profileHandler struct{} diff --git a/website/content/docs/schema/permanode b/website/content/docs/schema/permanode index 48a31d704..cbcd25cff 100644 --- a/website/content/docs/schema/permanode +++ b/website/content/docs/schema/permanode @@ -129,7 +129,7 @@ camliPath:bar.txt = $blobref_bartxt_permanode It will appear as a directory containing "dir2" and - "bar.txt". (NOTE(hjfreyer): is the value necessarily a permanode?). + "bar.txt".
These are used by a few things, including the website UI, the "publish" code (declaring you want a photo at a URL and then the @@ -138,5 +138,3 @@ read/write filesystem code. - -NOTE(hjfreyer): did I miss anything?