-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix for log tailer when the log file doesn't exist. #4528
Conversation
|
||
@file = ::File.open(path, 'r') | ||
if File.exists?(path) | ||
@cursor = ::File.size(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should initialize the variables regardless, probably setting it to nil.
Ok. Will issue a new PR with the changes |
A question: Is :: needed here (for File) or is it just best practice to use it ? On line 7 there is no :: for |
@tenderlove is this OK now? |
Fix for log tailer when the log file doesn't exist.
if ::File.exists?(path) | ||
@cursor = ::File.size(path) | ||
@file = ::File.open(path, 'r') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Y U NO USE an else there to assign cursor and file to nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brevity :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who needs readability?
@file, @cursor = ::File.exists?(path) ? [::File.open(path, 'r'), ::File.size(path)] : nil
This needs to be merged into 3-2-stable
|
@tenderlove please merge into 3-2-stable |
Fix for log tailer when the log file doesn't exist.
If the log file doesn't exist, log tailer errors out and takes down the server with it. Currently this does not happen because even if the log directory doesn't exist, https://github.com/rails/rails/blob/master/railties/lib/rails/application/bootstrap.rb#L27 creates it and the log file will be created.