display banner and add agent's reset values
This commit is contained in:
parent
0bebfd84aa
commit
4c9163ce64
@ -28,6 +28,7 @@ Find more information at:
|
|||||||
https://github.com/qiniu/goc
|
https://github.com/qiniu/goc
|
||||||
`,
|
`,
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
log.DisplayGoc()
|
||||||
// init logger
|
// init logger
|
||||||
log.NewLogger()
|
log.NewLogger()
|
||||||
},
|
},
|
||||||
|
@ -37,4 +37,6 @@ func (b *Build) Build() {
|
|||||||
|
|
||||||
// inject cover vars
|
// inject cover vars
|
||||||
cover.Inject()
|
cover.Inject()
|
||||||
|
|
||||||
|
// build in the temp project
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,16 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
waitDelay time.Duration = 10 * time.Second
|
waitDelay time.Duration = 10 * time.Second
|
||||||
host string = "127.0.0.1:8080"
|
host string = "{{.Host}}"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// init host
|
||||||
|
host_env := os.Getenv("GOC_CUSTOM_HOST")
|
||||||
|
if host_env != "" {
|
||||||
|
host = host_env
|
||||||
|
}
|
||||||
|
|
||||||
var dialer = websocket.DefaultDialer
|
var dialer = websocket.DefaultDialer
|
||||||
|
|
||||||
// 永不退出,出错后统一操作为:延时 + conitnue
|
// 永不退出,出错后统一操作为:延时 + conitnue
|
||||||
@ -116,9 +122,9 @@ func (ga *GocAgent) ResetProfile(req *ProfileReq, res *ProfileRes) error {
|
|||||||
return fmt.Errorf("wrong command")
|
return fmt.Errorf("wrong command")
|
||||||
}
|
}
|
||||||
|
|
||||||
*res = `mode: atomic
|
resetValues()
|
||||||
qiniu.com/kodo/apiserver/server/main.go:32.49,33.13 1 30
|
|
||||||
qiniu.com/kodo/apiserver/server/main.go:42.49,43.13 1 0`
|
*res = `ok`
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -162,6 +168,22 @@ func loadFileCover(coverCounters map[string][]uint32, coverBlocks map[string][]t
|
|||||||
coverBlocks[fileName] = block
|
coverBlocks[fileName] = block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset counters
|
||||||
|
func resetValues() {
|
||||||
|
{{range $i, $pkgCover := .Covers}}
|
||||||
|
{{range $file, $cover := $pkgCover.Vars}}
|
||||||
|
clearFileCover(_cover.{{$cover.Var}}.Count[:])
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func clearFileCover(counter []uint32) {
|
||||||
|
for i := range counter {
|
||||||
|
counter[i] = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// get process meta info for register
|
// get process meta info for register
|
||||||
type processInfo struct {
|
type processInfo struct {
|
||||||
hostname string
|
hostname string
|
||||||
|
16
pkg/log/display.go
Normal file
16
pkg/log/display.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package log
|
||||||
|
|
||||||
|
import "github.com/mgutz/ansi"
|
||||||
|
|
||||||
|
const banner = `
|
||||||
|
__ _ ___ ___
|
||||||
|
/ _ |/ _ \ / __|
|
||||||
|
| (_| | (_) | (__
|
||||||
|
\__, |\___/ \___|
|
||||||
|
|___/
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
|
func DisplayGoc() {
|
||||||
|
stdout.Write([]byte(ansi.Color(banner, "cyan+b")))
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user