Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory after logrotation #6

Open
gaiottino opened this issue Dec 18, 2010 · 5 comments
Open

No such file or directory after logrotation #6

gaiottino opened this issue Dec 18, 2010 · 5 comments

Comments

@gaiottino
Copy link
Contributor

Hi,

I'm using em-tail to tail apache log files but I'm running into problems when the files are rotated by Apache. I get the following exception

Tailing started
Tailer(/mnt/var/log/apache2/access-20101218130000.log) @ pos:
Found: /mnt/var/log/apache2/access-20101218130000.log
Tailer(/mnt/var/log/apache2/access-20101218131500.log) @ pos:
Found: /mnt/var/log/apache2/access-20101218131500.log

/home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-tail-0.5.20101204110840/lib/em/filetail.rb:178:in `initialize': No such file or directory - /mnt/var/log/apache2/access-20101218130000.log (Errno::ENOENT)
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-tail-0.5.20101204110840/lib/em/filetail.rb:178:in `open'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-tail-0.5.20101204110840/lib/em/filetail.rb:178:in `open'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-tail-0.5.20101204110840/lib/em/filetail.rb:280:in `block in schedule_reopen'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-0.12.10/lib/eventmachine.rb:996:in `call'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-0.12.10/lib/eventmachine.rb:996:in `block in run_deferred_callbacks'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-0.12.10/lib/eventmachine.rb:996:in `each'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-0.12.10/lib/eventmachine.rb:996:in `run_deferred_callbacks'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
    from /home/daniel/.rvm/gems/ruby-1.9.2-p0@zen/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
    from tailer.rb:41:in `'

You can see the code I'm testing with here: https://gist.github.com/746500

It seems it's trying to recreate a FileTail with the old path.

@gaiottino
Copy link
Contributor Author

Watching the log just now I saw that the exception was thrown several seconds after it created a new tailer for the new file. Perhaps it received an updated/new event instead of deleted once apache finished the logrotation.

Since the errors is in the initialize method it feels like it's actually trying to create a new tailer for that log.

@gaiottino
Copy link
Contributor Author

After adding

return unless File.exists?(@path)

to line 178 and 202 solves the issue but that feels like a hack.

@jordansissel
Copy link
Owner

Thanks for filing :)

I'll work on a test case that reproduces it (I can reproduce it by hand) and get a fix committed, soon.

@gaiottino
Copy link
Contributor Author

Any progress on this?

@jordansissel
Copy link
Owner

Not yet, I've been busy managing SysAdvent this month. Today's the last day for it, so I'll have free time to fix this (and other pending todos) after it's all over ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants