When automation testing is running I cannot connect to the testing computer and check the log file to check the progress of the testing because I would interrupt the testing. I can map the hdd and check the file this way but I want to add new feature to my sinatra application.
The application runs the tests and displays the test results so I want to add realtime stream of the log file via sintra. The log file could be even 2MB big so I guess it won't be a good idea to send the whole file every time an update to the log file was made although the server client communication will be done in 99% over LAN only. I would also like to have the latest last line from the log file at the top of a web browser.
Could someone suggest how to do that?
I can think of an ajax call made on regular basis that would pass to sinatra a number of the line that was received as a last one. And sinatra would return any update if available.
update
- Windows 7 64 bit
- ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
- sinatra (1.3.3)
- sinatra-contrib (1.3.1)
- sinatra-reloader (1.0)
Here is an example using "push", i.e. WebSockets:
Minimum Websocket Nodejs Tail Example
In my opinion AJAX polling is a duct-tape type of solution to this kind of problem. WebSockets is the way to go, and done correctly will have very little impact on system performance.
By googling "websockets sinatra" you can search for similar solutions for Sinatra, like the first hit for example:
https://github.com/simulacre/sinatra-websocket