kplex
kplex copied to clipboard
tail -f like behavior for input file interfaces
Add tail -f like behavior to input file interfaces.
Do you want to clone the "tail" branch? Hard week but I got some coding in on the train before the gin took effect. Needs cleaning up but should work like this: You need to specify persist=yes but with a regular filename (persist previously only worked with FIFOs). persist=fromstart will keep trying to open a file which isn't there when kplex starts up. Once opened, persist=yes or persist=fromstart should have tail-like behaviour. When EOF is reached kplex will close the file and re-stat it every
I'll have a look. Thanks for the quick implementation!
Needs some tidying. Pushed one fix this morning. Have to make ptys work the same way too....
I haven't had a chance to look at the new functionality yet - I hope to shortly.
When kplex starts up, does it first seek to the end of the file, and then start pushing the data out? Or does it start at the beginning of the file, send it all, and then wait for more data to arrive?
In the case of the file being smaller.... Maybe it should start from the beginning? As if the file it is reading from is a log file that's been truncated? I'm not sure...
It starts at the beginning, sends it all, closes the file, then periodically stats the file. If it grows it opens the file again, seeks to the point it left off and reads from there. If the file shrinks it currently logs an error message and exits but as you say maybe that's not the right thing to do and it should start again from the beginning
Do you think you could add an option that would have kplex on startup, seek to the end of the file, and then periodically stat the file from there on?
I'll look into it later this week