|The stupid question is the question not asked|
Simultaneously reading from a file and serving databy wazoox (Prior)
|on Feb 27, 2014 at 17:29 UTC||Need Help??|
wazoox has asked for the
wisdom of the Perl Monks concerning the following question:
I'm looking for an elegant way of reading data from a file on one hand, and serve it (preferably through a websocket) on the other hand. So far I managed to solve elegantly the problem of reading the output from several programs simultaneously by using on of the big powers of Unix : named pipes. However now I'm stuck on the next part: serving data. As reading from a pipe is blocking, and so is listening to a socket, I don't know how to get out of this.
So here's the code:
Of course the script work by commenting out one of the two loops, either the websocket one, or the file reading one. To use this script, create a named pipemkfifo toto1
run continuously vmstat and/or iostat and redirect their output to the pipe:vmstat 3 |tee toto1
andiostat -x 3 | tee toto1.
I don't know how to get any further from there... maybe golang? :)