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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.