File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -70,22 +70,24 @@ type Client struct {
70
70
var ErrNoInstance = errors .New ("no instance" )
71
71
72
72
func (p Client ) Call (xl * xlog.Logger , urlPath string , events []Event ) (err error ) {
73
+
73
74
if len (events ) == 0 {
74
75
return
75
76
} else if len (events ) > MaxBatchSize {
76
77
return ErrTooManyEvents
77
78
}
78
- pr , pw := io .Pipe ()
79
- go func () {
80
- err := json .NewEncoder (pw ).Encode (events )
81
- pw .CloseWithError (err )
82
- }()
83
79
84
80
hidx , obj := p .hosts .Select (xl )
85
81
if obj == nil {
86
82
return ErrNoInstance
87
83
}
88
84
85
+ pr , pw := io .Pipe ()
86
+ go func () {
87
+ err := json .NewEncoder (pw ).Encode (events )
88
+ pw .CloseWithError (err )
89
+ }()
90
+
89
91
defer func () {
90
92
if err != nil {
91
93
p .hosts .OnFailure (hidx )
Original file line number Diff line number Diff line change @@ -2,14 +2,28 @@ package main
2
2
3
3
import (
4
4
"flag"
5
+ "net/http"
6
+ _ "net/http/pprof"
5
7
"runtime"
6
8
9
+ "github.com/qiniu/log.v1"
7
10
"pili.qiniu.com/dsync.v1"
8
11
)
9
12
10
13
func main () {
11
14
12
- runtime .GOMAXPROCS (2 )
13
15
c := flag .String ("f" , "pili-dsync.conf" , "<config file>" )
16
+ pprof := flag .String ("pprof" , "" , "<pprof addr>" )
17
+
18
+ flag .Parse ()
19
+
20
+ if * pprof != "" {
21
+ log .Info ("pprof running at:" , * pprof )
22
+ go func () {
23
+ log .Println (http .ListenAndServe (* pprof , nil ))
24
+ }()
25
+ }
26
+
27
+ runtime .GOMAXPROCS (2 )
14
28
dsync .Main (* c )
15
29
}
You can’t perform that action at this time.
0 commit comments