Results 1 to 10 of 10

Thread: PHP-CLI for AGI and Exiting Cleanly (Process Control Needed)

  1. #1
    rpurinton Guest

    Default PHP-CLI for AGI and Exiting Cleanly (Process Control Needed)

    According to PHP/AGI best practices for exiting cleanly...
    On hangup from the caller, Asterisk will kill your script with SIGHUP; you can use pcntl_signal to run a user-defined function at this time.

    Code:
     pcntl_signal(SIGHUP,  "agi_hangup_handler");
     function agi_hangup_handler($signo) {
         //this function is run when Asterisk kills your script ($signo is always 1)
         //close file handles, write database records, etc.
     __
    According to PHP docs, for pcntl_signal to be available:
    Process Control support in PHP is not enabled by default. You have to compile the CGI or CLI version of PHP with --enable-pcntl configuration option when compiling PHP to enable Process Control support.
    Is there anyway I can recompile the CLI version of PHP on a live PIKA without having to go back to PADS to make all new images to have this feature enabled?

    Without adding this signal handler, there is no way for an AGI/PHP script to clean up or continue processing after the caller hangs up, the script is just killed.

    Thanks

  2. #2
    agauthier Guest

    Default PHP-CLI for AGI

    Currently, the only way to update this is through PADS.
    Out of curiosity, are you using the FreePBX distribution for Warp?
    This type of flag might be good to enable for the next version of FreePBX.

  3. #3
    rpurinton Guest

    Default

    We are running the PIKA with our own blend of freepbx using mysql. Our images were based on PIKA's very first release of FreePBX with MySQL.

    I agree this sounds like it should definetely be turned on for this purpose.

  4. #4
    agauthier Guest

    Default PHP-CLI for AGI .mk file

    The file that needs to be changed is
    <PADS_DIR>/package/php/php.mk

    Then add the -- switch to
    PHP_CONFIGURE_OPTS

  5. #5
    rpurinton Guest

    Default

    I have done this then ran

    make php-dirclean
    make php
    make image

    I have loaded the images on a WARP box and found that PHP is unable to connect to MySQL. The mysqld is running, and I can connect to it using the asterisk username and password from the command prompt, but when accessing the FreePBX gui, the error is presented:

    FATAL ERROR

    DB Error: connect failed


    When I go for a more specific reason I get:
    Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    I find no file in /tmp/ named mysql.sock

    When i run a script that executed phpInfo();

    I do see:

    Configure Command './configure' '--host=_____pc-linux' '--target=_____pc-linux' '--program-prefix=' '--prefix=/root/freepbx-mysql/2.0.0.94/build_warp/root/usr' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-all' '--disable-debug' '--with-pic' '--disable-rpath' '--enable-pcntl' '--enable-curl' '--with-curl=/root/freepbx-mysql/2.0.0.94/build_warp/root/usr' '--enable-gettext' '--with-gettext=/root/freepbx-mysql/2.0.0.94/build_warp/root/usr' '--enable-iconv' '--with-iconv=/root/freepbx-mysql/2.0.0.94/build_warp/root/usr' '--with-layout=GNU' '--enable-fastcgi' '--enable-cli' '--enable-ctype' '--enable-magic-quotes' '--enable-memory-limit' '--enable-libxml' '--with-libxml-dir=/root/freepbx-mysql/2.0.0.94/build_warp/root/usr' '--enable-xml' '--enable-mysq' '--with-mysql=/root/freepbx-mysql/2.0.0.94/build_warp/root/usr' '--enable-eaccelerator' '--disable-ipv6' '--enable-session' '--enable-pdo' '--with-pcre-regex' '--enable-posix' '--enable-pear' '--with-pear=/usr/share/pear' '--with-tags='

    I'm noticing the "--enable-mysq" and wondering if that should be --enable-mysql however farther down the page:

    mysql

    MySQL SupportenabledActive Persistent Links 0 Active Links 0 Client API version 5.1.30 MYSQL_MODULE_TYPE external MYSQL_SOCKET /tmp/mysql.sock MYSQL_INCLUDE -I/root/freepbx-mysql/2.0.0.94/build_warp/root/usr/include/mysql MYSQL_LIBS -L/root/freepbx-mysql/2.0.0.94/build_warp/root/usr/lib -lmysqlclient
    DirectiveLocal ValueMaster Valuemysql.allow_persistentOnOnmysql.connect_timeo ut6060mysql.default_hostno valueno valuemysql.default_passwordno valueno valuemysql.default_portno valueno valuemysql.default_socketno valueno valuemysql.default_userno valueno valuemysql.max_linksUnlimitedUnlimitedmysql.max_persist entUnlimitedUnlimitedmysql.trace_modeOffOff

    pcntl

    pcntl supportenabled

    Any help on this? Should I change that configure option to --enable-mysql? It appears this is how the php.mk comes default. as it even shows here:
    http://svn.pikatech.com/pads/addons/...hes/php/php.mk

    I'm not sure where to from here. I have recompiled and reinstalled twice.

  6. #6
    rpurinton Guest

    Default

    Resolved... checked out /etc/my.cnf to find the location of the mysql.sock on the PIKA...

    fixed the problem with
    ln -s /persistent2/mysql/usr/var/mysql.sock /tmp/mysql.sock

    I'm not sure why this problem arose after just changing that configuration option and rebuilding. Will retest my other AGI scripts now that pcntl is enabled.

  7. #7
    rpurinton Guest

    Default

    AGI scripts now terminate cleanly with --enable-pcntl

  8. #8
    rpurinton Guest

    Default

    The fix I applied for MySQL did not withstand a reboot. What would be the proper way to fix this permanently on the images?

  9. #9
    agauthier Guest

    Default mysql

    if you check /etc you should notice that /etc/my.cnf points to /persistent/etc/my.cnf

    You need to edit the file in /persistent/etc/my.cnf

  10. #10
    skar Guest

    Default pcntl added in trunk

    The flag recommended by rpurinton has been added to the svn trunk code of FreePBX on PADS as of revision number 18489.

    Thanks for the tip rpurinto.

    Skar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •