hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.72k stars 504 forks source link

fix block until exists function #68

Closed miraclesu closed 8 years ago

miraclesu commented 8 years ago

When we run the flow program, then execute echo 1 > not_exist in shell, the result is not we want to.

package main

import (
    "fmt"

    "github.com/hpcloud/tail"
)

func main() {
    t, err := tail.TailFile("not_exists", tail.Config{
        Follow:    true,
        MustExist: false,
    })

    if err != nil {
        fmt.Printf("err=%+v\n", err)
        return
    }

    for {
        select {
        case line := <-t.Lines:
            fmt.Printf("line=%s\n", line)
        }
    }
}
miraclesu commented 8 years ago

What is the ci happen? The tests passed in my local env (1.3.3, 1.4.2 and 1.5.1)

Nino-K commented 8 years ago

@miraclesu thanks for your contribution. I checkout your branch, I was unable to successfully run the tests(it hangs). I am more than happy to review this PR once the CI is passing.

miraclesu commented 8 years ago

@Nino-K thanks for your response. I run the tests again and all tests pass. The command list:

gvm use go1.5.2 && go env

mkdir -p /data/tmp/go && export GOPATH='/data/tmp/go' && go get github.com/hpcloud/tail
cd /data/tmp/go/src/github.com/hpcloud/tail

git remote add fix_block https://github.com/miraclesu/tail.git
git fetch fix_block
git checkout -b block_until_exists fix_block/fix/block_until_exists
go test

gvm use go1.4.3 && export GOPATH='/data/tmp/go'
go test

gvm use go1.3.3 && export GOPATH='/data/tmp/go'
go test

The result: tail

Could you give me more information of your test?

miraclesu commented 8 years ago

@Nino-K try add go install after the command of cd $HOME/gopath/src/github.com/hpcloud/tail in CI. Maybe the old .a file case the hang.

miraclesu commented 8 years ago

When watch multi files in the same parent directory, the BlockUntilExists will select the same chan, the result is not our expect. move to #69.