Jonas Kellens
2014-Mar-20 14:26 UTC
[asterisk-users] php script in h context makes channel hang : solution ?
Hello, I execute the following php script when a call ends and the h-context is executed : /exten => h,n,System(/usr/bin/php /var/log/asterisk/loggingAST/loggingAST.php /var/log/asterisk/loggingAST/${CHANNEL:4}.csv)/ The script loggingAST.php writes some information in a MySQL database on a remote webserver. I have noticed that when the webserver is unreachable, this channel "hangs" and Asterisk can not clear the channel and rtp ports. Is there a way to have the channel cleared, even if it takes some time to execute the php script ?? Kind regards, Jonas. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20140320/6f93a46d/attachment.html>
Eric Wieling
2014-Mar-20 14:40 UTC
[asterisk-users] php script in h context makes channel hang : solution ?
This is an excerpt from a script I use for post processing received faxes. You need the PHP process extension, on CentOS that is the php-process package. .... <end of code which interacts with asterisk> declare(ticks=1); // become a daemon so we don't tie up asterisk resources while we process the fax $pid = pcntl_fork(); if ($pid == -1) { die("could not fork"); } else if ($pid) { exit(); // we are the parent } // we are the child // detatch from the controlling terminal if (posix_setsid() == -1) { die("could not detach from terminal"); } // be nice and lower our priority (and the priority of any spawned processes) proc_nice(10); <start of code which can be run in the background after the channel went away> .... -----Original Message----- From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Jonas Kellens Sent: Thursday, March 20, 2014 10:27 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [asterisk-users] php script in h context makes channel hang : solution ? Hello, I execute the following php script when a call ends and the h-context is executed : exten => h,n,System(/usr/bin/php /var/log/asterisk/loggingAST/loggingAST.php /var/log/asterisk/loggingAST/${CHANNEL:4}.csv) The script loggingAST.php writes some information in a MySQL database on a remote webserver. I have noticed that when the webserver is unreachable, this channel "hangs" and Asterisk can not clear the channel and rtp ports. Is there a way to have the channel cleared, even if it takes some time to execute the php script ?? Kind regards, Jonas.