I have a web application that I use to spawn another program at the user's request. I would like to be able to display a progress bar for the user in the web app...but am a bit confused on how to do that. I have most of the pieces, but can't seem to get it all together. My spawned process (currently) spits out the number of lines processed on a periodic basis to STDOUT (but would prefer this to be more elegant IPC), which I would like to capture while the external program is running and send that back to the user interface via a Websocket connection as a percent complete in a javascript progress bar.
Currently, the external program writes its progress to STDOUT, I have a javascript widget that will accept the progress percentage, I have the web socket connection. What I don't have is a method for executing the external program (I am assuming IPC::Open3, IPC::Run3 or similar) and watching the progress within a loop (while?) until the program terminates (normally or not...I can handle abnormal exits already). During the loop execution, I would like to send the percentage of completion as it is received with a threshold set for the minimum interval between updates (already can handle the update frequency).
Any help or suggestions would be greatly appreciated...I guess that my first attempt at this would be to simply watch STDOUT use a regex to grab the formatted progress updates...but how do I break out of the loop? A not so sophisticated approach is to write "FINISHED" to STDOUT and watch for that...but that seems a bit unsophisticated and prone to errors.
In reply to capture periodic updates from external program by mabossert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |