http://qs1969.pair.com?node_id=11113786

Tommy has asked for the wisdom of the Perl Monks concerning the following question:

Looking for advice on how to best accomplish this in 2020. The last node I could find mentioning polling files was from 2004.

Rationale: I have a log file I want to tail out to the browser via Mojolicious websockets. I have a rudimentary solution in place where an XHR request is sent on a 10 second interval to the server (client pull) which then goes and checks for updates a la qx(tail -n50 $file) ... basically.

Having seen how awesome websockets can be, I want to use a sever-push model instead. The websockets logic is already in place... I just need to know how best to approach the file polling. Something like d/inotify maybe? Or stat() wrapped in a while loop (yuck)?

Thoughts??

Tommy
A mistake can be valuable or costly, depending on how faithfully you pursue correction