When using --input-file it should exit once file is fully read

This commit is contained in:
Leonid Bugaev
2017-06-27 13:56:14 +02:00
parent aa4a878436
commit b3dffae66f
2 changed files with 13 additions and 5 deletions
+6 -5
View File
@@ -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() {
+7
View File
@@ -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 {