6
6
"expvar"
7
7
"flag"
8
8
"fmt"
9
+ "github.com/buger/goreplay"
9
10
"log"
10
11
"net/http"
11
12
"net/http/httputil"
@@ -71,23 +72,23 @@ func main() {
71
72
}
72
73
73
74
args := os .Args [1 :]
74
- var plugins * InOutPlugins
75
+ var plugins * goreplay. InOutPlugins
75
76
if len (args ) > 0 && args [0 ] == "file-server" {
76
77
if len (args ) != 2 {
77
78
log .Fatal ("You should specify port and IP (optional) for the file server. Example: `gor file-server :80`" )
78
79
}
79
80
dir , _ := os .Getwd ()
80
81
81
- Debug (0 , "Started example file server for current directory on address " , args [1 ])
82
+ goreplay . Debug (0 , "Started example file server for current directory on address " , args [1 ])
82
83
83
84
log .Fatal (http .ListenAndServe (args [1 ], loggingMiddleware (args [1 ], http .FileServer (http .Dir (dir )))))
84
85
} else {
85
86
flag .Parse ()
86
- checkSettings ()
87
- plugins = NewPlugins ()
87
+ goreplay . CheckSettings ()
88
+ plugins = goreplay . NewPlugins ()
88
89
}
89
90
90
- log .Printf ("[PPID %d and PID %d] Version:%s\n " , os .Getppid (), os .Getpid (), VERSION )
91
+ log .Printf ("[PPID %d and PID %d] Version:%s\n " , os .Getppid (), os .Getpid (), goreplay . VERSION )
91
92
92
93
if len (plugins .Inputs ) == 0 || len (plugins .Outputs ) == 0 {
93
94
log .Fatal ("Required at least 1 input and 1 output" )
@@ -101,20 +102,20 @@ func main() {
101
102
profileCPU (* cpuprofile )
102
103
}
103
104
104
- if Settings .Pprof != "" {
105
+ if goreplay . Settings .Pprof != "" {
105
106
go func () {
106
- log .Println (http .ListenAndServe (Settings .Pprof , nil ))
107
+ log .Println (http .ListenAndServe (goreplay . Settings .Pprof , nil ))
107
108
}()
108
109
}
109
110
110
111
closeCh := make (chan int )
111
- emitter := NewEmitter ()
112
- go emitter .Start (plugins , Settings .Middleware )
113
- if Settings .ExitAfter > 0 {
114
- log .Printf ("Running gor for a duration of %s\n " , Settings .ExitAfter )
112
+ emitter := goreplay . NewEmitter ()
113
+ go emitter .Start (plugins , goreplay . Settings .Middleware )
114
+ if goreplay . Settings .ExitAfter > 0 {
115
+ log .Printf ("Running gor for a duration of %s\n " , goreplay . Settings .ExitAfter )
115
116
116
- time .AfterFunc (Settings .ExitAfter , func () {
117
- log .Printf ("gor run timeout %s\n " , Settings .ExitAfter )
117
+ time .AfterFunc (goreplay . Settings .ExitAfter , func () {
118
+ log .Printf ("gor run timeout %s\n " , goreplay . Settings .ExitAfter )
118
119
close (closeCh )
119
120
})
120
121
}
0 commit comments