coredns/middleware/pprof/setup.go
Miek Gieben 4723fb9418 Gofmt all code (#552)
* Gofmt all code

* fmt
2017-02-22 16:06:20 +00:00

42 lines
695 B
Go

package pprof
import (
"sync"
"github.com/coredns/coredns/middleware"
"github.com/mholt/caddy"
)
func init() {
caddy.RegisterPlugin("pprof", caddy.Plugin{
ServerType: "dns",
Action: setup,
})
}
func setup(c *caddy.Controller) error {
found := false
for c.Next() {
if found {
return middleware.Error("pprof", c.Err("pprof can only be specified once"))
}
if len(c.RemainingArgs()) != 0 {
return middleware.Error("pprof", c.ArgErr())
}
if c.NextBlock() {
return middleware.Error("pprof", c.ArgErr())
}
found = true
}
h := &handler{}
pprofOnce.Do(func() {
c.OnStartup(h.Startup)
c.OnShutdown(h.Shutdown)
})
return nil
}
var pprofOnce sync.Once