var tail = spawn('ssh', ['user@yourserver.com', 'tail', '-f', '/path/to/some.log']); tail.stdout.addListener('data', function (data) { listener.broadcast(data.toString()); });
I did a really simple version of what you're talking about with some client-side parsing of rails logs for fun. Feel free to contact me and I'll be happy to zip up the source and send it your way.
So what I did now is that basically I've made a 'forever frame' in my html which points to a URI where app resides. That app now outputs multipart/x-mixed-replace MIME which is then loaded into an iframe in my html and JS copied when onLoad happens to a styled div.
I've made a small proof of concept here:
- here is a straight sample output (in this case a dummy php): http://www.vga.hr/console_test/count.php
since this is a multipart/x-mixed-replace, I can blurt out a html (as 'Start' is) and plain afterwards.
- here is a simple client html: http://www.vga.hr/console_test/con_out.html - and another one which concatenates: http://www.vga.hr/console_test/con_out_plus.html
so my idea was basically to output text/html <script> out when I need to issue commands to a reader (for commands like overwrite mode, concatenate mode, highlight, clear, flash... whatever - basically a state machine) and text/plain for actual messages being shown.
I wish I could get rid of 'loading' status in browser while doing a long poll as primitive as I am now (forever frame).
tl;dr; should be on a client side only with x-mixed-replace on server.
Thanks again.