From b576dcc4813c22f0fe193b0c54b9632e49cfc494 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Fri, 4 Oct 2013 21:24:24 -0700 Subject: [PATCH 1/4] serverconfig: conditionally install expvar handler. Add local copy of the standard library's expvar handler. Change-Id: Ida41553345d7d29665f33268356bf16a80386e38 --- doc/environment-vars.txt | 3 +++ pkg/serverconfig/serverconfig.go | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) 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/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{} From 01f65d3b75ef339be52f6e2df2a5a6662bf76adb Mon Sep 17 00:00:00 2001 From: Steve Phillips Date: Sat, 5 Oct 2013 12:12:15 -0700 Subject: [PATCH 2/4] CONTRIBUTORS: s/assigment/assignment/ Change-Id: I8b226de20b95fa487d8cf5c0412a687bd5a71cae --- CONTRIBUTORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 45f72f5ab..344553c17 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. From 616acae745eadb34fd386ffccf07fb95ef6c77bd Mon Sep 17 00:00:00 2001 From: mpl Date: Mon, 7 Oct 2013 23:28:55 +0200 Subject: [PATCH 3/4] website: clean up overlooked notes. Change-Id: Ida760b727d7fa9f45f553dad2096afca47cbfac4 --- website/content/docs/schema/permanode | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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? From fc09b38397e5d979a8fedeb1be308877d4ec95fb Mon Sep 17 00:00:00 2001 From: Steve Phillips Date: Tue, 8 Oct 2013 11:47:45 -0700 Subject: [PATCH 4/4] verifyGoVersion: log.Fatalf was missing 'version' var Change-Id: I10c71e96a598ec640131245b73ae201161f68622 --- make.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) } }