How to make a permanent readstream

19 views
Skip to first unread message

jinzho...@gisticinc.com

unread,
Jan 25, 2018, 8:59:41 PM1/25/18
to nodejs

Scenario: I have a log file on server. One service consistently writes information to this file. I want to process every piece of massage wrote to the file and output to some destination.

Idea: If a read stream can keep in flowing mode and its "end" event never be emitted, I believe it will read every new line attached to the log file.

Question: Can we set a read stream permanent? Or, Can we use method to delete end symbol of the file therefore read stream never knows the file is end and keeps reading "null"s?

Joe Langeway

unread,
Jan 28, 2018, 10:52:26 PM1/28/18
to nodejs
I agree that a mode for reading a growing file would be useful, but if the mean time, have you tried spawning a child progress of ‘tail -f $FILE’ and reading its standard out? That’d be a performance problem if you’ve got lots of these but in the situation you describe I think it’d work fine.
Reply all
Reply to author
Forward
0 new messages