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

Use a JS only tail implementation #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

teid
Copy link

@teid teid commented Mar 21, 2020

In order to have the same behaviour between Linux and Windows (related to this issue: #197), I've switched to a lib that provide a JS only tail

This is still a work in progress, I still have to test it on Windows server, but I don't have it right now.

  • During a file rotation, we may loose couple of lines (until the retry). The native tail handle this in a better way though.
  • When we tail multiple files, tail has a syntax to display it:
test1.log sam. 21 mars 2020 17:54:08 CET
test1.log sam. 21 mars 2020 17:54:10 CET
test1.log sam. 21 mars 2020 17:54:11 CET
==> ../frontail/logs/test2.log <==
test2.log sam. 21 mars 2020 17:54:15 CET
test2.log sam. 21 mars 2020 17:55:04 CET
test2.log sam. 21 mars 2020 17:55:10 CET
test2.log sam. 21 mars 2020 17:55:12 CET
==> ../frontail/logs/test1.log <==
test1.log sam. 21 mars 2020 17:55:14 CET
test1.log sam. 21 mars 2020 17:55:17 CET
test1.log sam. 21 mars 2020 17:55:38 CET
test1.log sam. 21 mars 2020 17:55:47 CET

With this implementation, it's difficult to reproduce the same, so I changed the output (also, I allowed stdin to be followed along with other files):

../frontail/logs/test1.log - test1.log sam. 21 mars 2020 17:54:08 CET
../frontail/logs/test1.log - test1.log sam. 21 mars 2020 17:54:10 CET
../frontail/logs/test1.log - test1.log sam. 21 mars 2020 17:54:11 CET
../frontail/logs/test2.log - test2.log sam. 21 mars 2020 17:54:15 CET
                     stdin - stdin.log sam. 21 mars 2020 17:54:19 CET
                     stdin - stdin.log sam. 21 mars 2020 17:54:59 CET
                     stdin - stdin.log sam. 21 mars 2020 17:55:01 CET
                     stdin - stdin.log sam. 21 mars 2020 17:55:02 CET
../frontail/logs/test2.log - test2.log sam. 21 mars 2020 17:55:10 CET
../frontail/logs/test2.log - test2.log sam. 21 mars 2020 17:55:12 CET
../frontail/logs/test1.log - test1.log sam. 21 mars 2020 17:55:17 CET

Let me know what do you think about it :)

lib/tail.js Outdated
}
});

function readLastLinesIfPossible(path, onLineCb) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this function, because the native tail does it. But the JS lib does not

lib/tail.js Outdated Show resolved Hide resolved
test/tail.js Outdated Show resolved Hide resolved
@teid teid force-pushed the useJsTail branch 2 times, most recently from 680d9c9 to fc35ea6 Compare March 22, 2020 14:37
@mthenw
Copy link
Owner

mthenw commented Mar 31, 2020

@teid is it ready to be reviewed?

@teid
Copy link
Author

teid commented Apr 1, 2020

Yes @mthenw, I validated that this change fixes the issue I had on the Windows server

@kubawolanin
Copy link

Does this look mergeable @mthenw?
For me branch with @teid's work (thank you!) is the only way allowing me to use frontail with multiple files on Windows server.
Cheers

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

Successfully merging this pull request may close these issues.

3 participants