Jump to content

Real Time Scrpt Output via Web Page


dsn

Recommended Posts

I have a intranet site I have written in PHP for my company.

Some features are controlling services on various boxes in our infastructure.

At first this wasn't a problem but as the site grows and there are more servers in the farm I have noticed large amounts of "Hang Time" when scripts are executing in the background.

 

Simple Sample Code

<?

output=`sudo /path/to/script`;

echo $output;

?>

 

I have tried various other methods for accomplishing this even looking at different langs.

I tried having the process run in the Background sending Stdout to a file and have a Loop in PHP to read the file and dump the data from Stdout to HTML again the problem is it seems to wait until it has completed before rendering any data.

 

Is there any way around this? I am thinking something like an Ajax Log Viewer window in the page would solve the problem but even though its async I keep getting the "Hang" and "Pop" effect when the page renders.

 

This causes confusion in the application to the user as for example when I say restart Tomcat / Apache in the farm there is a 10 second wait between Tomcat Starting and Apache Starting to allow resources to finish releasing after deploying webapps and with 10 + Servers this is over 1 1/2 mintues of sleep time in the script alone. So you take that plus execution time and the page takes 2-3 minutes to render while I find my users freaking out not knowing what is going on and hitting refresh and doubling up command execution and causing other problems.

 

I tried Perl, I tried RoR, but when it comes to it I prefer PHP and would like to make this work in PHP.

Link to comment
https://forums.phpfreaks.com/topic/150512-real-time-scrpt-output-via-web-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.