mirror of
https://github.com/buger/goreplay.git
synced 2026-10-19 16:15:42 +00:00
When using --input-file it should exit once file is fully read
This commit is contained in:
@@ -32,7 +32,10 @@ func loggingMiddleware(next http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
var closeCh chan int
|
||||
|
||||
func main() {
|
||||
closeCh = make(chan int)
|
||||
// // Don't exit on panic
|
||||
// defer func() {
|
||||
// if r := recover(); r != nil {
|
||||
@@ -84,17 +87,15 @@ func main() {
|
||||
|
||||
if Settings.exitAfter > 0 {
|
||||
log.Println("Running gor for a duration of", Settings.exitAfter)
|
||||
closeCh := make(chan int)
|
||||
closeCh = make(chan int)
|
||||
|
||||
time.AfterFunc(Settings.exitAfter, func() {
|
||||
log.Println("Stopping gor after", Settings.exitAfter)
|
||||
close(closeCh)
|
||||
})
|
||||
|
||||
Start(closeCh)
|
||||
} else {
|
||||
Start(nil)
|
||||
}
|
||||
|
||||
Start(closeCh)
|
||||
}
|
||||
|
||||
func finalize() {
|
||||
|
||||
@@ -222,6 +222,13 @@ func (i *FileInput) emit() {
|
||||
}
|
||||
|
||||
log.Printf("FileInput: end of file '%s'\n", i.path)
|
||||
|
||||
// For now having fixed timeout is temporary solution
|
||||
// Further should be modified, so outputs can report if their queue empty or not
|
||||
time.Sleep(time.Second)
|
||||
if closeCh != nil {
|
||||
close(closeCh)
|
||||
}
|
||||
}
|
||||
|
||||
func (i *FileInput) Close() error {
|
||||
|
||||
Reference in New Issue
Block a user