Jump to content

Recommended Posts

Howdy,

 

I'm having some trouble with a script of mine and was hoping someone would be able to point me in the right direction...

 

Heres the jist of it: My company recently switched over to an asterisk phone system and i've been taksed with writing our helpdesk app that tracks the realtime progress of our queues and helpdesk techs. To accomplish this I've got a cronjob that starts the program and keeps it running all day long. It opens a socket to our asterisk server and has all phone events passed to the program via the socket. It then parses the applicable events into useful informaiton in a mysql server.

 

It works beautfully, execpt that the program will randomly time out. Very randomly. I haven't been able to establish any traits of the timeout. I have tried to set the max execution time to 0 in the php.ini file (which I know is not the ideal way to do this), and I have also tried setting it on the fily with set_time_limit(0). The probelm I then encounter is that instead of receiving a max execution time exceeded error and it killing my program, then program will run, but seemingly freeze and stop updating the database.

 

I'm running php 4.3.9, and I've included what I think are the valid parts of the script below.

 

 

This is the main

$ast = new AstMan();
$out = $ast->Login();


$today = date('w');
if($today == 0 || $today == 6)
$end = "1500"; // 3 o clock in the afternoon
else
$end = "2000"; // 8 o clock at night
$i = 0;
do
{
if($i == 0)
	$event = $ast->Query("Action: events\r\nEventmask: on\r\n\r\n");
else
	$event = $ast->GetSockData();
if(!eregi("Event: PeerStatus", $event) && !eregi("Event: NewExten", $event))
	super_size_me($event);
$time = date("Gi");
$i++;

}while($time < $end);
$ast->LogOut();

 

 

And this is where it is timing out...

 function GetSockData(){ 
   $wrets = ""; 
   if ($this->socket === FALSE) 
     return FALSE; 
   do 
   { 
     $line = fgets($this->socket, 4096); 
     $wrets .= $line; 
     $info = stream_get_meta_data($this->socket); 
   }while ($line != "\r\n"); 
   return $wrets; 
} 

 

Again, any help I receive is extremely welcome and appreciated.

Link to comment
https://forums.phpfreaks.com/topic/67307-php-cli-script-timing-out/
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.