KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to work out the best way to read data that is being written to a file, using node.js, in real time. Trouble is, Node is a fast moving ship which makes finding the best method for addressing a problem difficult. What I Want To Do I have a java process that is doing something and then writing the results of this thing it does to a text file. It typically takes anything from 5 mins to 5 hours to run, with data being written the whole time, and can get up to some fairly hefty throughput rates (circa. 1000 lines/sec). I would like to read this file, in real time, and then, using node aggregate the data and write it to a socket where it can be graphed on the client. The client, graphs, sockets and aggregation logic are all done but I am confused about the best approach for reading the file. What I Have Tried (or at least played with) FIFO - I can tell my Java process to write to a fifo and read this using node, this is in fact how we have this currently implemted using Perl, but because everything else is running in node it makes sense to port the code over. Unix Sockets - As above. fs.watchFile - will this work for what we need? fs.createReadStream - is this better than watchFile? fs & tail -f - seems like a hack. What, actually, is my Question I am tending towards using Unix Sockets, this seems the fastest option. But does node have better built-in features for reading files from the fs in real time?
Tags (comma-separated)
Save Edits
Cancel